Shiva Krishna Bavandla
Shiva Krishna Bavandla

Reputation: 26668

Export button is not visible with django-import-export package

I am trying to use django-import-export module in my admin and here are my settings

admin.py

from import_export.admin import ImportExportMixin, ImportMixin, ExportActionModelAdmin, ImportExportActionModelAdmin

class RegistrationAdmin(ImportExportActionModelAdmin):
    list_display = ('user', 'activation_key_expired')
    raw_id_fields = ['user']
    search_fields = ('user__username', 'user__first_name', 'user__last_name')

admin.site.register(RegistrationProfile, RegistrationAdmin)

With the above code, i can able to see an Import button in admin as below

enter image description here

But i can't able to see Export option, so what's the problem what am i missing here ?

I have seen some ticket about export button permission here https://github.com/django-import-export/django-import-export/issues/38 ? can anyone please let me know what need to be done in order for Export to appear ?

By the way i am using django suit as my admin theme

Upvotes: 1

Views: 2449

Answers (2)

VENKATESH K S
VENKATESH K S

Reputation: 41

You need to use ImportExportModelAdmin

Eg:

from django.contrib import admin
from .models import Question, Choice
from import_export.admin import ImportExportModelAdmin


# Register your models here.

@admin.register(Question)
class ViewAdmin(ImportExportModelAdmin):
    pass


@admin.register(Choice)
class ViewAdmin(ImportExportModelAdmin):
    pass

Upvotes: 1

Sayse
Sayse

Reputation: 43300

You need to use ImportExportModelAdmin

ImportExportActionModelAdmin only adds the export to the list of things you can do to selected items (see the dropdown in your screenshot)

Docs for ImportExportActionModelAdmin state

Export functionality is implemented as an admin action.

Upvotes: 3

Related Questions