From 23361fdba9f6dc6141156decaacf9bc63f8652e2 Mon Sep 17 00:00:00 2001 From: Bai Date: Wed, 19 Jul 2023 19:54:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B5=84=E4=BA=A7?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E5=AF=BC=E5=85=A5=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98(ID=E6=B2=A1=E6=9C=89=E8=BF=94=E5=9B=9E)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/drf/parsers/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/common/drf/parsers/base.py b/apps/common/drf/parsers/base.py index 9ba77ca72..6d4a745df 100644 --- a/apps/common/drf/parsers/base.py +++ b/apps/common/drf/parsers/base.py @@ -52,14 +52,15 @@ class BaseFileParser(BaseParser): fields_map = {} fields = self.serializer_fields for k, v in fields.items(): - if v.read_only: + # 资产平台的 id 是只读的, 导入更新资产平台会失败 + if v.read_only and k not in ['id', 'pk']: continue fields_map.update({ v.label: k, k: k }) field_names = [ - fields_map.get(column_title.strip('*'), '') + fields_map.get(column_title.strip('*').lower(), '') for column_title in column_titles ] return field_names