django-import-export: cannot exclude id field during import : KeyError: u'id'

后端 未结 3 1739
无人共我
无人共我 2020-12-18 17:15

On Django-1.9.6, django-import-export-0.5

When I try to upload CSV without \"id\" field throws this error.

Line number: 1 - u\'id\'
13173474, Harry          


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-18 17:38

    Seems "django-import-export" still using the default one 'id'. for the time been, included a column 'id' in the header in CSV file and excluded importing in resources.py

    class edxUserResource(resources.ModelResource):
    
        class Meta:
            model = edxUser
            skip_unchanged = True
            report_skipped = True
            exclude = ('id',)
            import_id_fields = ('edx_id', 'edx_email', 'edx_name',)
            #export_order = ('edx_id', 'edx_email')
    

提交回复
热议问题