Opened 5 years ago

Closed 5 years ago

Last modified 4 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:

Description

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 5 years ago by pandres

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from nobody to pandres
  • Patch needs improvement unset

comment:2 Changed 5 years ago by pandres

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 5 years ago by pandres

  • Owner changed from pandres to nobody

comment:4 Changed 5 years ago by lukeplant

  • Resolution set to invalid
  • Status changed from new to closed

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 4 years ago by jacob

  • milestone 1.3 deleted

Milestone 1.3 deleted

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