I have a short question about django-import-export. In my model I have choice list:
STATE_CHOICES = ((NEW_STATE, u'New'),
(DELIVERED_STATE, u'Delivered'),
(LOST_STATE, u'Lost'),
And method that handles mapping choices for names
@staticmethod
def get_status_name_by_status(status):
return next((s[1] for s in MyModel.STATE_CHOICES if s[0] == status), 'Uknown')
I want to import/export some data
class MyModelResource(resources.ModelResource):
status = fields.Field(column_name='status', attribute='order',
widget=ForeignKeyWidget(Order, 'status'))
I want to use my get_status_name_by_status method so the choices will be converted to names. But there is no possibility to use method here, only fields are allowed. Any tip how this can be done ?