From abe6c5defefc7057e7fb5f47b79643f7b89f7d90 Mon Sep 17 00:00:00 2001 From: Jezeniel Zapanta Date: Tue, 31 Oct 2017 05:08:15 +0800 Subject: Fixed #28514 -- Clarifed docs about idempotence of RelatedManager.add(). --- docs/ref/models/relations.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'docs/ref/models') diff --git a/docs/ref/models/relations.txt b/docs/ref/models/relations.txt index beffe1283e..9814485445 100644 --- a/docs/ref/models/relations.txt +++ b/docs/ref/models/relations.txt @@ -56,11 +56,15 @@ Related objects reference manager perform the update by calling ``e.save()``. Using ``add()`` with a many-to-many relationship, however, will not - call any ``save()`` methods, but rather create the relationships - using :meth:`QuerySet.bulk_create() + call any ``save()`` methods (the ``bulk`` argument doesn't exist), but + rather create the relationships using :meth:`QuerySet.bulk_create() `. If you need to execute some custom logic when a relationship is created, listen to the - :data:`~django.db.models.signals.m2m_changed` signal. + :data:`~django.db.models.signals.m2m_changed` signal, which will + trigger ``pre_add`` and ``post_add`` actions. + + Using ``add()`` on a relation that already exists won't duplicate the + relation, but it will still trigger signals. .. method:: create(**kwargs) -- cgit v1.3