#35125: Parent model fields are ignored when preparing the update_fields
-------------------------------------+-------------------------------------
Reporter: Gustavo Silva | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 4.2
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: update_or_create | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Gustavo Silva):
Hi Natalia, thank you very much for your reply!
Replying to [comment:1 Natalia Bidart]:
> Hello Gustavo! Thanks for your report.
>
> If I understand your second part of the report correctly, your issue is
similar to the one described in this forum post:
https://forum.djangoproject.com/t/update-or-create-behavior/25944/ (while
the first post is about a new feature request, I think the underlying
issue is the same and you may benefit from the posted answers). If yes,
could you please add your proposal/concern to that topic? Or you could
also create a new topic to present your idea, since you'll reach a wider
audience and likely get extra feedback in the forum than here.
Thank you for pointing me in that direction. I will take a look to that
post and will try to see if it is the same problem - and being so I can
propose a fix there, sure.
Replying to [comment:1 Natalia Bidart]:
> For the first part of the report, could you please cite the exact part
of the linked doc that you find confusing?
I highlighted the bits that was confusing but perhaps they are only
confusing when considering the release notes and/or the queryset
reference. So, the model field reference says this about `auto_now`:
> The field is only automatically updated when calling Model.save(). The
field isn’t updated when making updates to other fields in other ways such
as QuerySet.update(), though you can specify a custom value for the field
in an update like that.
https://docs.djangoproject.com/en/4.2/ref/models/fields/#django.db.models.DateField.auto_now
But the release notes mention this, about the fields that are picked up
for updates: https://docs.djangoproject.com/en/4.2/releases/4.2/#setting-
update-fields-in-model-save-may-now-be-required
The docs for phttps://docs.djangoproject.com/en/5.0/ref/models/querysets
/#update-or-create/ the `update_or_create` method also mention that after
4.2 only some fields are selected for update.
All of this in conjunction, led me to believe auto_now fields do not get
picked up for updates after 4.2 but maybe it's only my interpretation, I
don't know.
--
Ticket URL: <https://code.djangoproject.com/ticket/35125#comment:2>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/0107018d212a008a-1a64d7f2-35ac-43e5-a9f2-7f1373b14d7a-000000%40eu-central-1.amazonses.com.