我正在尝试使用django-import-export
and django-admin-sortable2
,但它们似乎不能同时工作。
我第一次有这个:
from import_export.admin import ImportExportActionModelAdmin
class PageAdmin(ImportExportActionModelAdmin):
并且导入和导出都按预期出现并发挥作用。然后我补充说SortableAdminMixin
:
from import_export.admin import ImportExportActionModelAdmin
from adminsortable2.admin import SortableAdminMixin
class PageAdmin(SortableAdminMixin,ImportExportActionModelAdmin):
排序功能出现了,但这似乎与导入功能冲突,导入按钮消失了。我尝试重新订购:
from import_export.admin import ImportExportActionModelAdmin
from adminsortable2.admin import SortableAdminMixin
class PageAdmin(SortableAdminMixin,ImportExportActionModelAdmin):
这一次,这些项目不再可排序,但重新出现了导入按钮。我也尝试过分离导入和导出:
from import_export.admin import ExportActionModelAdmin, ImportMixin
from adminsortable2.admin import SortableAdminMixin
class PageAdmin(ImportMixin,SortableAdminMixin,ExportActionModelAdmin):
但无济于事。我如何让这些管理员混音器相互配合?
每个mixin具有的功能:
def change_list_template(self):
def __init__(self, model, admin_site):
def _get_update_url_name(self):
def get_urls(self):
def get_actions(self, request):
def get_changelist(self, request, **kwargs):
def media(self):
def _add_reorder_method(self):
def update_order(self, request):
def save_model(self, request, obj, form, change):
def move_to_exact_page(self, request, queryset):
def move_to_back_page(self, request, queryset):
def move_to_forward_page(self, request, queryset):
def move_to_first_page(self, request, queryset):
def move_to_last_page(self, request, queryset):
def _get_order_direction(self, request):
def _move_item(self, request, startorder, endorder):
def get_extra_model_filters(self, request):
def get_max_order(self, request, obj=None):
def _bulk_move(self, request, queryset, method):
def changelist_view(self, request, extra_context=None):
def get_update_url(self, request):
def get_skip_admin_log(self):
def get_tmp_storage_class(self):
def get_urls(self):
def get_resource_kwargs(self, request, *args, **kwargs):
def get_import_resource_kwargs(self, request, *args, **kwargs):
def get_resource_class(self):
def get_import_resource_class(self):
def get_import_formats(self):
def process_import(self, request, *args, **kwargs):
def process_dataset(self, dataset, confirm_form, request, *args, **kwargs):
def process_result(self, result, request):
def generate_log_entries(self, result, request):
def add_success_message(self, result, request):
def get_import_context_data(self, **kwargs):
def get_context_data(self, **kwargs):
def import_action(self, request, *args, **kwargs):
看起来唯一常见的功能是 get_urls - 这可能是冲突的地方吗?