0

试图关注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'.

如何created使用 django-model-utils 在管理面板中显示值?

4

1 回答 1

0

根据错误,它看起来像created并且modified不是模型上的属性 ( meetings.Company)。

您确定已将这些字段添加到您的Company模型中吗?

如果这不能解决您的问题,您可以将您的模型添加到问题中。

于 2021-01-17T14:49:21.973 回答