Django管理面板应用程序模型list_display未显示

时间:2018-01-15 19:11:19

标签: python django django-models django-admin-filters

这是我的代码

from django.contrib import admin

from farmer.models import *

class listAllFarmer(admin.ModelAdmin):
    list_display = ('username', 'code')
    admin.site.register(allFarmers, listAllFarmer)

如果我写这个只是它有效

from django.contrib import admin

from farmer.models import *
admin.site.register(allFarmers)

1 个答案:

答案 0 :(得分:0)

您应该在课堂外添加admin.site.register

from django.contrib import admin

from farmer.models import *

class listAllFarmer(admin.ModelAdmin):
    list_display = ('username', 'code')

admin.site.register(allFarmers, listAllFarmer)