0

I'm trying to enable the "Export selected" button in the Django admin for users to download data as an Excel sheet. I'm using django-import-export but the button isn't appearing.

Here's what I've done: Installed django-import-export (pip install django-import-export).

Trial 1:

class UserAdmin(ImportExportModelAdmin):
    list_display = ('username', 'email'....)

admin.site.unregister(User)
admin.site.register(User, ImportExportModelAdmin)

Trial 2:

class UserAdmin(ExportMixin, admin.ModelAdmin):
    list_display = ('username', 'email'.....)
admin.site.unregister(User)
admin.site.register(User, UserAdmin)

Restarted the development server.

the django-import-export is in INSTALLED_APPS in settings.py

Expected behavior: The "Export selected" button should appear in the Django admin user list view.

Actual behavior: The button is not displayed.

My Question: Why the button is not showing and how can I fix it.

Any suggestions or insights into why the button might not be showing would be greatly appreciated.

3
  • Docs for enabling export are here. Try with the example app for reference. If still not working, it could be a clash with other plugins you may have. Commented Mar 19, 2024 at 19:43
  • @toyotaSupra I am not sure what you mean it should appear in the Django Admin Commented Mar 19, 2024 at 22:23
  • You can ignore the comment from toyota Supra - it is not relevant to django-import-export Commented Mar 21, 2024 at 11:23

1 Answer 1

1

Here is how I enabled using the example app.

  1. Use django-import-export v4.

  2. Go to the 'Category' model instance and add some new categories.

  3. You can now select and export:

enter image description here

To enable this, simply subclass ExportActionModelAdmin (refer to example code):

class CategoryAdmin(ExportActionModelAdmin):
    pass

admin.site.register(Category, CategoryAdmin)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.