这是我的代码
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)
答案 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)