当我从excel导入数据时,我发现默认ID是随机的:
ID NAME
5 A
9 B
我希望它在导入数据时看起来像下面的示例" NAME:A,NAME:B"来自excel:
ID NAME
1 A
2 B
我该怎么做?
class assets_resource(resources.ModelResource):
class Meta:
model = assets
skip_unchanged = True
report_skipped = False
@admin.register(assets)
class data_import(ImportExportModelAdmin):
list_display = ['id', 'sn']
search_fields = ['id', 'sn']
ordering = ['id', 'sn']
resource_class = assets_resource