Django-Import-Export未显示在Admin界面GUI中

时间:2018-01-31 19:20:08

标签: python django django-import-export

我一直按照说明让django-import-export http://django-import-export.readthedocs.io/en/latest/库与我的模型一起使用(用于将产品导入我的产品模型)。导入/导出命令不会显示在管理GUI上。

from import_export import resources
from django.contrib import admin
from .models import Product, Category
from import_export.admin import ImportExportModelAdmin, ImportMixin, ExportMixin, ImportExportMixin

class ProductResource(resources.ModelResource):
    class Meta:
        model = Product

# Register your models here.
admin.site.register(Product)

class ProductAdmin(ImportExportModelAdmin):
    resource_class = ProductResource

admin.site.register(Category)

1 个答案:

答案 0 :(得分:0)

您好像忘记注册ProductAdmin。改变这个:

admin.site.register(Product)

对此:

admin.site.register(Product, ProductAdmin)