我有一个定义日期时间字段的模型:
dateAdded = models.DateTimeField("Date Added", auto_now_add=True)
在我的 ModelAdmin 子类中,我试图在以下字段集中显示该字段:
fieldsets = (
(None, {
'fields': (
("modelId", "altModelIds", "modelName", "dateAdded"),
("manufacturer", "protocol", "category"),
("versionAdded", "proOnly", "published", "discontinued"),
"notes"
)
}),
但我收到以下错误:
FieldError: Unknown field(s) (dateAdded) specified for Device
不过,有趣的是,当我将它添加到 list_display 时:
list_display = ("modelName", "published", "modelId", "altModelIds", "manufacturer", "protocol", "category", "dateAdded")
它工作正常。我确定我只是在做一些愚蠢的事情(我已经离开 Django 大约 8 个月了),但我想不通。任何帮助,将不胜感激。