Django-import-export. Export selected records only?

111 Views Asked by At

I'm using the great django-import-export addition.

We standard have 2 options import and export. I would like to have an extra option to export selected records only. Would be a nice addition. How can I achieve this?

I use the standard configuration in the Django admin.

1

There are 1 best solutions below

1
Matthew Hegarty On BEST ANSWER

Yes this is possible.

enter image description here

To do this, simply declare an Admin instance which inherits from ExportActionModelAdmin:

class CategoryAdmin(ExportActionModelAdmin):
    pass

Then register this Admin:

admin.site.register(Category, CategoryAdmin)

Note that the above example refers specifically to the Example app, you'll have to modify to refer to your own Model instances.