Opened 17 years ago

Closed 14 years ago

Last modified 14 years ago

#6434 closed (fixed)

auto_now and auto_now_add documentation

Reported by: jokull@… 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)

6434-dyn.patch (6.7 KB ) - added by Matthias Kestenholz 16 years ago.
auto-add-note.diff (580 bytes ) - added by Adam Vandenberg 14 years ago.
Alternate docs-only patch.

Download all attachments as: .zip

Change History (12)

comment:1 by Alex Gaynor, 17 years ago

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.

comment:2 by Jacob, 16 years ago

Triage Stage: UnreviewedAccepted

by Matthias Kestenholz, 16 years ago

Attachment: 6434-dyn.patch added

comment:3 by Matthias Kestenholz, 16 years ago

Cc: mk@… 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 Collin Anderson, 15 years ago

Summary: auto_now and auto_now_add should me marked for soon-to-be-deprecatedauto_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 Adam Nelson, 15 years ago

Owner: changed from nobody to Adam Nelson

Nobody seems to be working on this so I'll take it.

comment:7 by bjunix, 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.

by Adam Vandenberg, 14 years ago

Attachment: auto-add-note.diff added

Alternate docs-only patch.

comment:8 by Tim Graham, 14 years ago

Patch needs improvement: unset

comment:9 by Tim Graham, 14 years ago

Resolution: fixed
Status: newclosed

(In [14923]) Fixed #6434 - Add clarifying note about auto_now and auto_now_add. thank adamv for the patch.

comment:10 by Tim Graham, 14 years ago

(In [14924]) [1.2.X] Fixed #6434 - Add clarifying note about auto_now and auto_now_add. thank adamv for the patch.

Backport of r14923 from trunk.

Note: See TracTickets for help on using tickets.
Back to Top