Opened 12 years ago

Closed 9 years ago

Last modified 9 years ago

#6434 closed (fixed)

auto_now and auto_now_add documentation

Reported by: jokull@… Owned by: Adam Nelson
Component: Documentation Version: master
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

The and 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 11 years ago.
auto-add-note.diff (580 bytes) - added by Adam Vandenberg 9 years ago.
Alternate docs-only patch.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 12 years ago by Alex Gaynor

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 Changed 11 years ago by Jacob

Triage Stage: UnreviewedAccepted

Changed 11 years ago by Matthias Kestenholz

Attachment: 6434-dyn.patch added

comment:3 Changed 11 years ago by Matthias Kestenholz

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/

I think this functionality is used often and therefore might deserve a place in Django proper.


comment:4 Changed 10 years ago by Collin Anderson

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:

comment:5 Changed 9 years ago by Adam Nelson

Owner: changed from nobody to Adam Nelson

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

comment:7 Changed 9 years ago by bjunix

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.

Changed 9 years ago by Adam Vandenberg

Attachment: auto-add-note.diff added

Alternate docs-only patch.

comment:8 Changed 9 years ago by Tim Graham

Patch needs improvement: unset

comment:9 Changed 9 years ago by Tim Graham

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 Changed 9 years ago by Tim Graham

(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