django-import-export从'1'开始按顺序指定id

时间:2018-01-25 04:10:51

标签: python django django-import-export

当我从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

0 个答案:

没有答案