I have the following model
class Event(models.Model):
product_type = models.CharField(max_length=250, null=False, blank=False)
received_time = models.DateTimeField(editable=False)
in admin:
class EventAdmin(admin.ModelAdmin):
fields = ['product_type', 'received_time']
I get the following error when trying to edit an event (clicking on an individual event in the admin):
FieldError at /admin/events/event/20/
Unknown field(s) (received_time) specified for Event. Check fields/fieldsets/exclude attributes of class EventAdmin.
I do see that editable=False
but I still want it to at least be visible, even it it isn't editable. Is there a way to fix this error and edit these items in admin?
You need to keep it in readonly_fields
class EventAdmin(admin.ModelAdmin):
fields = ['product_type',]
readonly_fields=('received_time',)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With