如何显示在管理面板中从 TimeStampedModel 创建的
How to show created in admin panel from TimeStampedModel
正在尝试关注 https://github.com/jazzband/django-model-utils/issues/186
#admin.py
class CompanyAdmin(admin.ModelAdmin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.readonly_fields += (
"created",
"modified",
)
错误
django_1 | SystemCheckError: System check identified some issues:
django_1 |
django_1 | ERRORS:
django_1 | <class 'meetings.admin.CompanyAdmin'>: (admin.E035) The value of 'readonly_fields[0]' is not a callable, an attribute of 'CompanyAdmin', or an attribute of 'meetings.Company'.
django_1 | <class 'meetings.admin.CompanyAdmin'>: (admin.E035) The value of 'readonly_fields[1]' is not a callable, an attribute of 'CompanyAdmin', or an attribute of 'meetings.Company'.
如何使用 django-model-utils 在管理面板中显示 created
值?
根据错误,created
和 modified
似乎不是您模型的属性 (meetings.Company
)。
您确定已将这些字段添加到您的 Company
模型中吗?
如果这不能解决您的问题,能否将您的模型添加到问题中。
正在尝试关注 https://github.com/jazzband/django-model-utils/issues/186
#admin.py
class CompanyAdmin(admin.ModelAdmin):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.readonly_fields += (
"created",
"modified",
)
错误
django_1 | SystemCheckError: System check identified some issues:
django_1 |
django_1 | ERRORS:
django_1 | <class 'meetings.admin.CompanyAdmin'>: (admin.E035) The value of 'readonly_fields[0]' is not a callable, an attribute of 'CompanyAdmin', or an attribute of 'meetings.Company'.
django_1 | <class 'meetings.admin.CompanyAdmin'>: (admin.E035) The value of 'readonly_fields[1]' is not a callable, an attribute of 'CompanyAdmin', or an attribute of 'meetings.Company'.
如何使用 django-model-utils 在管理面板中显示 created
值?
根据错误,created
和 modified
似乎不是您模型的属性 (meetings.Company
)。
您确定已将这些字段添加到您的 Company
模型中吗?
如果这不能解决您的问题,能否将您的模型添加到问题中。