djangodjango-import-export

Django-import-export. Export selected records only?


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.


Solution

  • 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.