list_display不起作用

时间:2015-06-05 07:19:46

标签: python django

if IP address == <my ip address> then ' do nothing here else country_georedirect() end if

中有一个名为Employees的班级
models.py

然后我在class Employees(models.Model): employee_id = models.CharField(verbose_name = _("Employee ID"), max_length=20, primary_key=True) employee_name = models.CharField(verbose_name = _("Employee Name"), max_length=20) department = models.CharField(verbose_name = _("Department"), max_length=100) post = models.CharField(verbose_name = _("Post"), max_length=100)

中写了一些代码
admin.py

根据教程,Employee分支中应该有四个字段。但在我的情况下,只有一个名为class EmployeesAdmin(admin.ModelAdmin): list_display = ('employee_id', 'employee_name', 'department', 'post') 的字段,就像我没有在Employees中添加EmployeesAdmin类一样。它出什么问题了?我错过了什么吗?

admin.py:

admin.py

2 个答案:

答案 0 :(得分:7)

在admin.site中注册您的管理员,如: -

admin.site.register(ModelName, AdminName)

答案 1 :(得分:2)

在admin.py中声明EmployeesAdmin课程后尝试以下操作:

admin.site.register(Employees, EmployeesAdmin)