However, I found that regarding a field with `auto_now=True` there is a
different outcome.
IOW, specifying `update_fields` can be used to keep the old date in
respective "auto_now=True"-field UNLESS that field is also explicitly
given un `update_fields`
This should be more prominently stated in the documentation.
In addition I also noticed that - using deserialization - `object.save()`
gives unexpected different results for auto_now field:
- if the object-pk already exists , the field is saved as given
- but if it does not exist, the given value is ignored, and the current
time is used instead
... very strange if you ask me...
refs:
[https://stackoverflow.com/questions/17474057/enforce-auto-now-when-using-
saveupdate-fields]
[https://groups.google.com/d/msg/django-users/sqMrUlZP2-8/FczIEwwMBAAJ]
--
Ticket URL: <https://code.djangoproject.com/ticket/30319>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
Comment:
It sounds quite clear for me that if you add fields with `auto_now` flag
to the list of `updated_fields` then its value will be updated. Due to the
different behavior with and without PK please check
[https://docs.djangoproject.com/en/dev/ref/models/instances/#how-django-
knows-to-update-vs-insert how-django-knows-to-update-vs-insert]. IMO
documentation doesn't require clarification here.
If you have other support questions please see
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
TicketClosingReasons/UseSupportChannels] for ways to get help with Django
usage (and yes I've seen that you've already posted on django-users).
--
Ticket URL: <https://code.djangoproject.com/ticket/30319#comment:1>
* resolution: invalid => wontfix
--
Ticket URL: <https://code.djangoproject.com/ticket/30319#comment:2>
Comment (by sebhaase):
I would still suggest to rephrase:
"There will be a slight performance benefit from preventing all of the
model fields from being updated in the database."
to
"There will be a slight performance benefit from preventing all of the
model fields from being updated in the database. Note that `auto_now=True`
fields will be stay untouched unless explicitly listed in
`update_fields`."
I'm sure I'm not the only who got tripped by this - otherwise the docs of
django a really superb!
--
Ticket URL: <https://code.djangoproject.com/ticket/30319#comment:3>
Comment (by Nick Pope):
This behaviour is now documented, see the
[https://github.com/django/django/pull/16124 PR].
--
Ticket URL: <https://code.djangoproject.com/ticket/30319#comment:4>