gpt4 book ai didi

python - list_display 不起作用

转载 作者:行者123 更新时间:2023-11-28 19:48:45 26 4
gpt4 key购买 nike

models.py 中有一个名为Employees 的类

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中写了一些代码

class EmployeesAdmin(admin.ModelAdmin):
list_display = ('employee_id', 'employee_name', 'department', 'post')

根据教程,Employee分支应该有四个字段。但在我的情况下,只有一个名为Employees 的字段,就像我没有在admin.py 中添加EmployeesAdmin 类一样。它出什么问题了?我错过了什么吗?


admin.py:

from django.contrib import admin
from .models import Employees, Purchase, ProductsOut

# Register your models here.
admin.site.register(Employees)
admin.site.register(Purchase)
admin.site.register(ProductsOut)

最佳答案

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

admin.site.register(ModelName, AdminName)

关于python - list_display 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30660619/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com