#27791: update_or_create() doesn't work properly when model has auto_now=True
-------------------------------------+-------------------------------------
Reporter: Andrew Chiw | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 1.10
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Tim Graham):
This looks like invalid usage of `auto_now`. As
[https://docs.djangoproject.com/en/stable/ref/models/fields/#django.db.models.DateField.auto_now
the documentation] says, "Automatically set the field to now every time
the object is saved. Useful for “last-modified” timestamps. Note that the
current date is always used; it’s not just a default value that you can
override." It seems like `update_or_create()` can't work intuitively with
an `auto_now` field as whatever value you specify is ignored.
I'm not sure if anything should be done to improve the situation
considering that there are suggestions to deprecate `auto_now`; see #22995
for details and alternatives.
--
Ticket URL: <https://code.djangoproject.com/ticket/27791#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/072.880b3e007bd625e3d13a8df99e4ba259%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.