You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Django users
auto_now_add automatically sets editable=False[1]. When editable=False,
the field isn't displayed in the admin[2]. To show these fields in the
admin but leave them non-editable, list them as read-only fields[3] like
this:
# admin.py
from .models import Question
@admin.register(Question)
class QuestionAdmin(admin.ModelAdmin):
readonly_fields = ['pub_date']
If you want these auto_now_add fields to be in the admin and editable,
I'm not sure, I've never done this. Maybe you can't explicitly set
editable=True on the field? Usually if I want to set a DateTime
automatically and also make it editable, I won't use auto_add_now.
Instead I'll override the save method and set the field there.