#36741: Explain why pre_save/post_save signals are skipped when using
QuerySet.update()
-------------------------------------+-------------------------------------
Reporter: Lam Phung | Owner:
Type: | Youngkwang Yang
Cleanup/optimization | Status: assigned
Component: Documentation | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Youngkwang Yang):
Additionally, the QuerySet.update() documentation's final paragraph
provides more detailed explanation about signals:
(https://docs.djangoproject.com/en/5.2/ref/models/querysets/#update)
{{{
Finally, realize that update() does an update at the SQL level and, thus,
does not call any save() methods on your models, nor does it emit the
pre_save or post_save signals (which are a consequence of calling
Model.save()). If you want to update a bunch of records for a model that
has a custom save() method, loop over them and call save(), like this:
for e in Entry.objects.filter(pub_date__year=2010):
e.comments_on = False
e.save()
}}}
What are your thoughts on this explanation?
--
Ticket URL: <https://code.djangoproject.com/ticket/36741#comment:3>
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 visit
https://groups.google.com/d/msgid/django-updates/0107019a97c75069-9a43573a-81c1-47e3-8ce2-2aae1406319f-000000%40eu-central-1.amazonses.com.