class import_export.fields.Field(attribute=None, column_name=None, widget=None, default=<class 'django.db.models.fields.NOT_PROVIDED'>, readonly=False, saves_null_values=True, dehydrate_method=None, m2m_add=False)

Field represents a mapping between an instance field and a representation of the field’s data.

  • attribute – A string of either an instance attribute or callable of the instance.

  • column_name – An optional column name for the column that represents this field in the export.

  • widget – Defines a widget that will be used to represent this field’s data in the export, or transform the value during import.

  • readonly – A Boolean which defines if this field will be ignored during import.

  • default – This value will be returned by clean() if this field’s widget returned a value defined in empty_values.

  • saves_null_values – Controls whether null values are saved on the instance. This can be used if the widget returns null, but there is a default instance value which should not be overwritten.

  • dehydrate_method – Lets you choose your own method for dehydration rather than using dehydrate_{field_name} syntax.

  • m2m_add – changes save of this field to add the values, if they do not exist, to a ManyToMany field instead of setting all values. Only useful if field is a ManyToMany field.

clean(row, **kwargs)

Translates the value stored in the imported datasource to an appropriate Python object and returns it.


Returns value from the provided instance converted to export representation.


Returns method name to be used for dehydration of the field. Defaults to dehydrate_{field_name}


Returns the value of the instance’s attribute.

save(instance, row, is_m2m=False, **kwargs)

If this field is not declared readonly, the instance’s attribute will be set to the value returned by clean().