diff options
| author | Loic Bistuer <loic.bistuer@sixmedia.com> | 2013-11-22 00:14:16 +0700 |
|---|---|---|
| committer | Anssi Kääriäinen <akaariai@gmail.com> | 2013-11-27 19:45:22 +0200 |
| commit | f450bc9f44bc1270eae911daa157c155c29d1d9d (patch) | |
| tree | 7d456e19e1e928d6616d7d0fe975feba87231be2 /docs | |
| parent | 52015b963d263642957aec880b52ad4063b484cd (diff) | |
Added a bulk option to RelatedManager remove() and clear() methods
Refs #21169
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/relations.txt | 14 | ||||
| -rw-r--r-- | docs/releases/1.7.txt | 11 |
2 files changed, 22 insertions, 3 deletions
diff --git a/docs/ref/models/relations.txt b/docs/ref/models/relations.txt index 2fca954676..0c47bc4047 100644 --- a/docs/ref/models/relations.txt +++ b/docs/ref/models/relations.txt @@ -110,6 +110,17 @@ Related objects reference the ``blog`` :class:`~django.db.models.ForeignKey` doesn't have ``null=True``, this is invalid. + .. versionchanged 1.7:: + + For :class:`~django.db.models.ForeignKey` objects, this method accepts + a ``bulk`` argument to control how to perform the operation. + If ``True`` (the default), ``QuerySet.update()`` is used. + If ``bulk=False``, the ``save()`` method of each individual model + instance is called instead. This triggers the + :data:`~django.db.models.signals.pre_save` and + :data:`~django.db.models.signals.post_save` signals and comes at the + expense of performance. + .. method:: clear() Removes all objects from the related object set:: @@ -121,7 +132,8 @@ Related objects reference them. Just like ``remove()``, ``clear()`` is only available on - :class:`~django.db.models.ForeignKey`\s where ``null=True``. + :class:`~django.db.models.ForeignKey`\s where ``null=True`` and it also + accepts the ``bulk`` keyword argument. .. note:: diff --git a/docs/releases/1.7.txt b/docs/releases/1.7.txt index a453301999..f8cdcf1f3b 100644 --- a/docs/releases/1.7.txt +++ b/docs/releases/1.7.txt @@ -430,6 +430,11 @@ Models * :class:`F expressions <django.db.models.F>` support the power operator (``**``). +* The ``remove()`` and ``clear()`` methods of the related managers created by + ``ForeignKey`` and ``GenericForeignKey`` now accept the ``bulk`` keyword + argument to control whether or not to perform operations in bulk + (i.e. using ``QuerySet.update()``). Defaults to ``True``. + Signals ^^^^^^^ @@ -589,11 +594,13 @@ Fixing the issues introduced some backward incompatible changes: - The default implementation of ``remove()`` for ``ForeignKey`` related managers changed from a series of ``Model.save()`` calls to a single ``QuerySet.update()`` call. The change means that ``pre_save`` and - ``post_save`` signals aren't sent anymore. + ``post_save`` signals aren't sent anymore. You can use the ``bulk=False`` + keyword argument to revert to the previous behavior. - The ``remove()`` and ``clear()`` methods for ``GenericForeignKey`` related managers now perform bulk delete. The ``Model.delete()`` method isn't called - on each instance anymore. + on each instance anymore. You can use the ``bulk=False`` keyword argument to + revert to the previous behavior. - The ``remove()`` and ``clear()`` methods for ``ManyToManyField`` related managers perform nested queries when filtering is involved, which may or |
