From 5861f7dac26ad41a88b18bfb862a9131e7235866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8C=BF=E5=B0=8F=E5=A4=A9?= <1638245306@qq.com> Date: Wed, 4 Jan 2023 17:48:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DBUG:=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=92=8C=E5=AF=BC=E5=85=A5=E6=9B=B4=E6=96=B0?= =?UTF-8?q?bug=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/dvadmin/utils/import_export.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/backend/dvadmin/utils/import_export.py b/backend/dvadmin/utils/import_export.py index 882ff4c..49534f5 100644 --- a/backend/dvadmin/utils/import_export.py +++ b/backend/dvadmin/utils/import_export.py @@ -18,6 +18,10 @@ def import_to_data(file_url, field_data, m2m_fields=None): file_path_dir = os.path.join(settings.BASE_DIR, file_url) workbook = openpyxl.load_workbook(file_path_dir) table = workbook[workbook.sheetnames[0]] + theader = tuple(table.values)[0] # Excel的表头 + is_update = '更新主键(勿改)' in theader # 是否导入更新 + if is_update is False: # 不是更新时,删除id列 + field_data.pop('id') # 获取参数映射 validation_data_dict = {} for key, value in field_data.items():