Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#14623 closed (invalid)

DateTimeField(auto_now=True) does not change when update is called

Reported by: mklauber Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords: DateTimeField auto_now
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


According to documentation, the auto_now property of a DateTimeField is supposed to be useful for tracking last modified dates. However, when Type.objects.filter(property1="value1").update(property2="value2") is called these fields are not updated. While the documentation does state that this value is changed when save() is called, the expected behavior is that any change to the record would result in this field updating.

Change History (5)

comment:1 Changed 7 years ago by pandres

Owner: changed from nobody to pandres

comment:2 Changed 7 years ago by pandres

Triage Stage: UnreviewedAccepted

comment:3 Changed 7 years ago by pandres

Owner: changed from pandres to nobody

comment:4 Changed 7 years ago by Luke Plant

Resolution: invalid
Status: newclosed

I really don't think that the docs for update() would give you the expectations you describe. It is very clear that it works on the level of an SQL update and the save() method is not called, and the docs for DateTimeField are equally clear that auto_now is applied when the object is saved. Django has DB access code on several levels, and we cannot add caveats for every single low level operation in the docs for every single high level operation.

comment:5 Changed 7 years ago by Jacob

milestone: 1.3

Milestone 1.3 deleted

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