Asked By – dotty
How come my “date” field doesn’t come up in the admin system?
In my admin.py file i have
from django.contrib import admin from glasses.players.models import * admin.site.register(Rating)
and the Rating model has a field called “date” which looks like this
date = models.DateTimeField(editable=True, auto_now_add=True)
However within the admin system, the field doesn’t show, even though
editable is set to
Does anyone have any idea?
Now we will see solution for issue: DateTimeField doesn’t show in admin system
I believe to reason lies with the
From this answer:
Any field with the auto_now attribute
set will also inherit editable=False
and therefore will not show up in the
Also mentioned in the docs:
As currently implemented, setting
auto_now or auto_now_add to True will
cause the field to have editable=False
and blank=True set.
This does make sense, since there is no reason to have the field editable if it’s going to be overwritten with the current datetime when the object is saved.