How to show created in admin panel from TimeStampedModel

152 Views Asked by At

trying to follow 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",
        )

error

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'.

How do you show the created value in the admin panel with django-model-utils ?

1

There are 1 best solutions below

1
On BEST ANSWER

Based on the error, it looks like created and modified are not attributes on your model (meetings.Company).

Are you sure you have added these fields to your Company model.

If this doesn't solve your problem, can you add your model to the question.