Search code examples
djangodjango-import-export

How to delete column before clicking on import using Django import export in admin


I want to delete some columns from a csv before I import it to the model In admin. It has some overridable functions in https://django-import-export.readthedocs.io/en/latest/api_resources.html#import_export.resources.Resource.after_import_row but I do not know how to edit it.

enter image description here


Solution

  • You can manipulate the tablib object in memory before you call the django-import-export import_data() function.

    For example, to remove a column, it is very simple:

    del data['Col Name']