summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorCarlton Gibson <carlton.gibson@noumenal.es>2020-02-18 10:48:19 +0100
committerCarlton Gibson <carlton.gibson@noumenal.es>2020-02-18 19:58:23 +0100
commit611d1c114835310a0cd963e20f3e9782c34db847 (patch)
tree88e06e635c3ebb10dfeb85b1e7b90dd1b88dd072 /docs
parent2448b3182c75cce5d22dd80be0fb5cba6104c364 (diff)
[3.0.x] Fixed #31282 -- Corrected RelatedManager docs for using add/remove/set with PKs.
Backport of 3bbf9a489afc689eff2f4a0b84af196aa1ef51e7 from master
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/models/relations.txt16
1 files changed, 8 insertions, 8 deletions
diff --git a/docs/ref/models/relations.txt b/docs/ref/models/relations.txt
index 67a6a41940..21d65c033d 100644
--- a/docs/ref/models/relations.txt
+++ b/docs/ref/models/relations.txt
@@ -66,8 +66,8 @@ Related objects reference
Using ``add()`` on a relation that already exists won't duplicate the
relation, but it will still trigger signals.
- ``add()`` also accepts the field the relation points to as an argument.
- The above example can be rewritten as ``b.entry_set.add(234)``.
+ For many-to-many relationships ``add()`` accepts either model instances
+ or field values, normally primary keys, as the ``*objs`` argument.
Use the ``through_defaults`` argument to specify values for the new
:ref:`intermediate model <intermediary-manytomany>` instance(s), if
@@ -131,9 +131,9 @@ Related objects reference
:data:`~django.db.models.signals.m2m_changed` signal if you wish to
execute custom code when a relationship is deleted.
- Similarly to :meth:`add()`, ``remove()`` also accepts the field the
- relation points to as an argument. The above example can be rewritten
- as ``b.entry_set.remove(234)``.
+ For many-to-many relationships ``remove()`` accepts either model
+ instances or field values, normally primary keys, as the ``*objs``
+ argument.
For :class:`~django.db.models.ForeignKey` objects, this method only
exists if ``null=True``. If the related field can't be set to ``None``
@@ -195,9 +195,9 @@ Related objects reference
race conditions. For instance, new objects may be added to the database
in between the call to ``clear()`` and the call to ``add()``.
- Similarly to :meth:`add()`, ``set()`` also accepts the field the
- relation points to as an argument. The above example can be rewritten
- as ``e.related_set.set([obj1.pk, obj2.pk, obj3.pk])``.
+ For many-to-many relationships ``set()`` accepts a list of either model
+ instances or field values, normally primary keys, as the ``objs``
+ argument.
Use the ``through_defaults`` argument to specify values for the new
:ref:`intermediate model <intermediary-manytomany>` instance(s), if