我对 django 导入导出工具有疑问。与本主题中描述的类似。问题是那里发布的问题没有解决方案,我非常需要它。我的管理面板中的导入/导出按钮不显示。是否更改了声明顺序,运行 collectstatic,重新启动服务器...
我可以使用你的帮助 django 大师。
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'