Fixed #28514 -- Clarifed docs about idempotence of RelatedManager.add().

This commit is contained in:
Jezeniel Zapanta 2017-10-31 05:08:15 +08:00 committed by Tim Graham
parent 1834490a0c
commit abe6c5defe
3 changed files with 9 additions and 4 deletions

View file

@ -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()
<django.db.models.query.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)