Problem with ForeignKeyWidget
See original GitHub issueI’m following the docs on ForeignKeyWidget very closely, and am still getting an error when uploading an Excel file. My resource looks like this:
class AssignmentResource(resources.ModelResource):
instruction_type = fields.Field(
column_name='instruction_type',
attribute='instruction_type',
widget=ForeignKeyWidget(InstructionType, 'type')
)
class Meta:
model = Assignment
fields = ('instruction_type',)
type
is a string field on the InstructionType
model. When I try to upload a spreadsheet that has string values, I get this error:
Line number: 1 - Column 'instruction_type': invalid literal for int() with base 10: 'Research'
What am I doing wrong?
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
How to solve MultipleObjectsReturned with ForeignKeywidget ...
Jaq / class 2 Lucy / class 2 # only 1 can have 2 as its a ForeignKey # same error will happen...
Read more >Problem with ForeignKeyWidget - - Bountysource
I'm following the docs on ForeignKeyWidget very closely, and am still getting an error when uploading an Excel file. My resource looks like...
Read more >Adding foreignKey widget to django-import-export - YouTube
Django : Adding foreignKey widget to django-import-export [ Beautify Your ... If there any issues, contact us on - htfyc dot hows dot...
Read more >Widgets — django-import-export 3.0.3.dev0 documentation
…using a ForeignKeyWidget has the advantage that it can not only be used for exporting, but also importing data with foreign key relationships....
Read more >django-import-export ForeignKeyWidget : r/django - Reddit
I can not get the ForeignKeyWidget to work when importing in the admin ... r/StableDiffusion - ModuleNotFoundError: No module named 'frontend' error in ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
🤦
So… I never actually added the line
resource_class = AssignmentResource
to myAssignmentAdmin
class.Sorry for the runaround!
I told myself I couldn’t possibly have forgotten this and lo and behold I checked and…I also forgot to do this. THANK YOU!