[Django]-How to access row data in before_save_instance for Django Import Export

4👍

It turns out you can get a list of the fields on the object in question with:

self.get_fields()

And you for a given field you can access the values for the instance passed into before_save_instance with:


field_value = None
try:
field_value = field.get_value(instance).all()
except AttributeError:
field_value = field.get_value(instance)

You can also override the before_insert_rows(self, rows, **kwargs) method to get access to the raw row information.

Leave a comment