Adding foreignKey widget to django-import-export

后端 未结 3 1899
野的像风
野的像风 2020-12-31 14:30

I\'m trying to import data to one of my models, but it\'s failing because I\'m trying to upload the foreignKey Id, not the iterated number that import-export creates.

<
3条回答
  •  不知归路
    2020-12-31 14:49

    Use the widget- works great.

    school_id = fields.Field(column_name='school_id', attribute='Sol', widget=widgets.ForeignKeyWidget(Sol, 'school_id'))

提交回复
热议问题