Django Import/Export to multiple Models (foreignkey)

删除回忆录丶 提交于 2019-12-06 09:39:06

Try

 store_name = fields.Field(column_name='store_name', attribute='Store',
                           widget=ForeignKeyWidget(Store, 'store_name'))

I suggest you name model field uncapitalized

It's hard to understand what you are really asking.

If what you are saying is that "Want to create foreign key objects and fill the foreign object's attribute with the excel data"

I think you need to do first create the foreign object and relate it to the other model which means, you would need to override or define a function in your ModelResource class and have it called from your admin.

They have a widget for this- http://django-import-export.readthedocs.org/en/latest/api_widgets.html. I do not understand how to use it tho.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!