question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot exclude id field during import : KeyError: u'id'

See original GitHub issue

am trying to import in admin and already excluded the id field but i get

Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/import_export/resources.py", line 434, in import_row
instance, new = self.get_or_init_instance(instance_loader, row)
File "/usr/local/lib/python2.7/dist-packages/import_export/resources.py", line 258, in get_or_init_instance
instance = self.get_instance(instance_loader, row)
File "/usr/local/lib/python2.7/dist-packages/import_export/resources.py", line 252, in get_instance
return instance_loader.get_instance(row)
File "/usr/local/lib/python2.7/dist-packages/import_export/instance_loaders.py", line 31, in get_instance
field = self.resource.fields[key]
KeyError: u'id'

why is it compulsory to include id field i thought it should be autogenerated

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:11
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
ydanielscommented, Feb 14, 2017

yes that’s what i did to fix the problem but i think its not necessary to include id field when importing new data, a fix for this in the package would be nice.

3reactions
jwzh222commented, Feb 8, 2017

i’m having the same issue, it seems like the meta class option import_id_fields doesn’t work when you give it a new value. it still using the default one ‘id’.

eventually, i have to change the xls file to add a column ‘id’ in header then import works

class SponsorBlockResource(resources.ModelResource):
  class Meta:
        model = SponsorBlock
        exclude = ('id', )
        import_id_fields = ('name',)
        skip_unchanged = True
        fields = ['name','block_time',]
Read more comments on GitHub >

github_iconTop Results From Across the Web

python - django-import-export: cannot exclude id field during ...
When I try to upload CSV without "id" field throws this error. Line number: 1 - u'id' 13173474, Harry McDade, 10.harry.asas@ ...
Read more >
[Answered]-django-import-export: cannot exclude id field ...
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 McDade, ......
Read more >
cannot exclude id field during import : KeyError: u'id' -
am trying to import in admin and already excluded the id field but i get. Traceback (most recent call last): File ...
Read more >
labelbox.schema.data_row_metadata — Python SDK reference 3.33 ...
Source code for labelbox.schema.data_row_metadata. # type: ignore from datetime import datetime from copy import deepcopy from enum import Enum from ...
Read more >
How do I fix KeyError Using Vals? - Odoo
Thanks for your subscription! keyerror. I have this code: import time from openerp.osv import fields, osv import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found