Skip to content

Commit 11f9fae

Browse files
VIZZARD-Xjacobtylerwalls
authored andcommitted
Fixed #36741 -- Linked to custom save()/delete() caveats in docs/ref/models/querysets.txt.
1 parent a89183e commit 11f9fae

2 files changed

Lines changed: 15 additions & 10 deletions

File tree

docs/ref/models/querysets.txt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,7 +2432,8 @@ are), and returns created objects as a list, in the same order as provided:
24322432

24332433
This has a number of caveats though:
24342434

2435-
* The model's ``save()`` method will not be called, and the ``pre_save`` and
2435+
* The model's ``save()`` method :ref:`will not be called
2436+
<methods-not-called-on-bulk-operations>`, and the ``pre_save`` and
24362437
``post_save`` signals will not be sent.
24372438
* It does not work with child models in a multi-table inheritance scenario.
24382439
* If the model's primary key is an :class:`~django.db.models.AutoField` or has
@@ -2513,7 +2514,8 @@ than iterating through the list of models and calling ``save()`` on each of
25132514
them, but it has a few caveats:
25142515

25152516
* You cannot update the model's primary key.
2516-
* Each model's ``save()`` method isn't called, and the
2517+
* Each model's ``save()`` method :ref:`isn't called
2518+
<methods-not-called-on-bulk-operations>`, and the
25172519
:attr:`~django.db.models.signals.pre_save` and
25182520
:attr:`~django.db.models.signals.post_save` signals aren't sent.
25192521
* If updating a large number of columns in a large number of rows, the SQL
@@ -2999,7 +3001,8 @@ and calling ``save()``.
29993001
such filter conditions on MySQL.
30003002

30013003
Finally, realize that ``update()`` does an update at the SQL level and, thus,
3002-
does not call any ``save()`` methods on your models, nor does it emit the
3004+
method :ref:`does not call<methods-not-called-on-bulk-operations>` any
3005+
``save()`` methods on your models, nor does it emit the
30033006
:attr:`~django.db.models.signals.pre_save` or
30043007
:attr:`~django.db.models.signals.post_save` signals (which are a consequence of
30053008
calling :meth:`Model.save() <django.db.models.Model.save>`). If you want to
@@ -3072,13 +3075,13 @@ This cascade behavior is customizable via the
30723075
:attr:`~django.db.models.ForeignKey.on_delete` argument to the
30733076
:class:`~django.db.models.ForeignKey`.
30743077

3075-
The ``delete()`` method does a bulk delete and does not call any ``delete()``
3076-
methods on your models. It does, however, emit the
3077-
:data:`~django.db.models.signals.pre_delete` and
3078-
:data:`~django.db.models.signals.post_delete` signals for all deleted objects
3079-
(including cascaded deletions). Signals won't be sent when ``DB_CASCADE`` is
3080-
used. Also, ``delete()`` doesn't return information about objects deleted from
3081-
database variants (``DB_*``) of the
3078+
The ``delete()`` method does a bulk delete and :ref:`does not call
3079+
<methods-not-called-on-bulk-operations>` any ``delete()`` methods on your
3080+
models. It does, however, emit the :data:`~django.db.models.signals.pre_delete`
3081+
and :data:`~django.db.models.signals.post_delete` signals for all deleted
3082+
objects (including cascaded deletions). Signals won't be sent when
3083+
``DB_CASCADE`` is used. Also, ``delete()`` doesn't return information about
3084+
objects deleted from database variants (``DB_*``) of the
30823085
:attr:`~django.db.models.ForeignKey.on_delete` argument, e.g. ``DB_CASCADE``.
30833086

30843087
Django won’t need to fetch objects into memory when deleting them in the

docs/topics/db/models.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,8 @@ example::
964964

965965
See :ref:`ref-models-update-fields` for more details.
966966

967+
.. _methods-not-called-on-bulk-operations:
968+
967969
.. admonition:: Overridden model methods are not called on bulk operations
968970

969971
Note that the :meth:`~Model.delete` method for an object is not

0 commit comments

Comments
 (0)