summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJezeniel Zapanta <jezeniel.zapanta@gmail.com>2017-10-31 05:08:15 +0800
committerTim Graham <timograham@gmail.com>2018-03-20 21:42:53 -0400
commit83362cb94a730c1c88752313e2b1b10ed5f436c0 (patch)
tree2cb56ecbed2134aca8177979adff6564673594a4
parent0cae6069dc906305da60f956f50ede2830203fd9 (diff)
[2.0.x] Fixed #28514 -- Clarifed docs about idempotence of RelatedManager.add().
Backport of abe6c5defefc7057e7fb5f47b79643f7b89f7d90 from master
-rw-r--r--AUTHORS1
-rw-r--r--docs/ref/models/relations.txt10
-rw-r--r--docs/topics/db/examples/many_to_many.txt2
3 files changed, 9 insertions, 4 deletions
diff --git a/AUTHORS b/AUTHORS
index 68772529bf..0d1e619f20 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -381,6 +381,7 @@ answer newbie questions, and generally made Django that much better:
Jeremy Dunck <jdunck@gmail.com>
Jeremy Lainé <jeremy.laine@m4x.org>
Jesse Young <adunar@gmail.com>
+ Jezeniel Zapanta <jezeniel.zapanta@gmail.com>
jhenry <jhenry@theonion.com>
Jim Dalton <jim.dalton@gmail.com>
Jimmy Song <jaejoon@gmail.com>
diff --git a/docs/ref/models/relations.txt b/docs/ref/models/relations.txt
index 9cb61d14ed..603c53dd11 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()
<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)
diff --git a/docs/topics/db/examples/many_to_many.txt b/docs/topics/db/examples/many_to_many.txt
index 7173faaeca..065ab1605b 100644
--- a/docs/topics/db/examples/many_to_many.txt
+++ b/docs/topics/db/examples/many_to_many.txt
@@ -75,7 +75,7 @@ Create another ``Article``, and set it to appear in both ``Publications``::
>>> a2.publications.add(p1, p2)
>>> a2.publications.add(p3)
-Adding a second time is OK::
+Adding a second time is OK, it will not duplicate the relation::
>>> a2.publications.add(p3)