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'
Remove , admin.ModelAdmin from this line and it should start working: class LibraryAdmin(ImportExportModelAdmin, admin.ModelAdmin):
After installing the django-import-export package using:
pip install django-import-export
Within the settings.py file, add 'import_export' to the list of installed apps:
INSTALLED_APPS = [ ... 'import_export' ... ]
Within the admin.py file, here is how to use the import_export package:
from django.contrib import admin
from import_export.admin import ImportExportModelAdmin
from .models import Bot
admin.site.register(Bot, ImportExportModelAdmin)
In my case, I was overriding Django admin list template:
{% extends "admin/change_list.html" %}
{% block object-tools-items %}
{{ block.super }}
<Code>
{% endblock %}
But in order for import_export buttons to appear, you need to override their template, so the first line should be:
{% extends "admin/import_export/change_list_import_export.html" %}