#6434 closed (fixed)
auto_now and auto_now_add documentation
Reported by: | Owned by: | Adam Nelson | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | datefield auto_now auto_now_add | |
Cc: | mk@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
http://www.djangoproject.com/documentation/model-api/#datefield[[BR]]
The datetime.datetime.now and datetime.date.today callables or a field subclass should probably be suggested to meet these needs.
Attachments (2)
Change History (12)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
by , 16 years ago
Attachment: | 6434-dyn.patch added |
---|
comment:3 by , 16 years ago
Cc: | added |
---|---|
Has patch: | set |
Keywords: | auto_now auto_now_add added |
Patch needs improvement: | set |
Some documentation is included but it's _very_ lacking. As per the discussion in a mailing list thread[1] I added Auto[Add]{Date,DateTime,Time}Field classes to django/db/models/fields/init.py
I think this functionality is used often and therefore might deserve a place in Django proper.
[1]: http://groups.google.com/group/django-developers/browse_thread/thread/4cd631c225cb4e52
comment:4 by , 15 years ago
Summary: | auto_now and auto_now_add should me marked for soon-to-be-deprecated → auto_now and auto_now_add documentation |
---|
I believe that the current attitude towards auto_now and auto_now_add is that they become editable=False automatically. This needs to be documented, and should probably explain the common pitfalls and recommend an alternative method.
Current documentation: http://docs.djangoproject.com/en/dev/ref/models/fields/#datefield
comment:5 by , 15 years ago
Owner: | changed from | to
---|
Nobody seems to be working on this so I'll take it.
comment:6 by , 15 years ago
comment:7 by , 14 years ago
I just stumbled upon this documentation 'bug'. tried to explicity include a DateField with auto_now_add=True in a ModelForm. After rethinking the problem it is clear that the auto_now_add field is not editable and thus excluded from the form automatically. But I think it would have helped if this behavior was documented somewhere.
comment:8 by , 14 years ago
Patch needs improvement: | unset |
---|
comment:9 by , 14 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Adding a default doesn't exactly do the same thing, you would also need to override the save method of the model(especially for auto_now), I also agree they should be deprecated, however we need to document the alternative.