Search code examples
djangodjango-admindjango-import-export

django-import-export not showing in admin


I have a problem with django import-export tool. Simmilat to the one described in This topic. Problem is there is no solution for the problem posted there and I need it badly. Buttons for import/export in my admin panel do not show up. Did change the order of declaration, run collectstatic, restarted server ...

I could use your help django masters.

 from django.contrib import admin
    #from actions import export_to_csv
    from import_export import resources
    from import_export.admin import ImportExportModelAdmin, ImportExportMixin, ImportMixin, ExportActionModelAdmin, ImportExportActionModelAdmin
    from .models import Library
    from datetime import datetime
    from django import forms
    from redactor.widgets import RedactorEditor

     # registered models

    class LibraryResource(resources.ModelResource):

        class Meta:
            model = Library

    class LibraryAdmin(ImportExportModelAdmin, admin.ModelAdmin):
        resource_class = LibraryResource

        list_display = ...
        list_display_links = ...
        search_fields =...
        list_filter = ...


        def name(self, obj):
            return obj.library.name
            name.admin_order_field  = 'name'  #Allows column order sorting
            name.short_description = 'Biblioteka'

Solution

  • Remove , admin.ModelAdmin from this line and it should start working: class LibraryAdmin(ImportExportModelAdmin, admin.ModelAdmin):