修复BUG: 新增导入和导入更新bug优化
parent
c0ed29dea2
commit
5861f7dac2
|
@ -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():
|
||||
|
|
Loading…
Reference in New Issue