summaryrefslogtreecommitdiff
path: root/docs/ref/models
diff options
context:
space:
mode:
authorClifford Gama <cliffygamy@gmail.com>2025-02-10 09:52:27 +0200
committerSarah Boyce <42296566+sarahboyce@users.noreply.github.com>2025-03-04 13:08:01 +0100
commitcc405e154649af37e1741aeb4438391943133c29 (patch)
tree0ee9944b86d3e124d923c7b9d15ce857ea01cff1 /docs/ref/models
parent03ace756eafc3f7a85f5b84d28ce1e7ce092c018 (diff)
[5.1.x] Fixed #36128 -- Clarified auto-generated unique constraint on m2m through models.
Backport of ae2736ca3bf4c6a27e23ee95530ad965b550d4cc from main.
Diffstat (limited to 'docs/ref/models')
-rw-r--r--docs/ref/models/fields.txt11
1 files changed, 3 insertions, 8 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 5a0ee47caa..7937baf031 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -2011,13 +2011,6 @@ that control how the relationship functions.
.. note::
- If you don't want multiple associations between the same instances, add
- a :class:`~django.db.models.UniqueConstraint` including the from and to
- fields. Django's automatically generated many-to-many tables include
- such a constraint.
-
- .. note::
-
Recursive relationships using an intermediary model can't determine the
reverse accessors names, as they would be the same. You need to set a
:attr:`~ForeignKey.related_name` to at least one of them. If you'd
@@ -2026,7 +2019,9 @@ that control how the relationship functions.
If you don't specify an explicit ``through`` model, there is still an
implicit ``through`` model class you can use to directly access the table
- created to hold the association. It has three fields to link the models.
+ created to hold the association. It has three fields to link the models, a
+ primary key and two foreign keys. There is a unique constraint on the two
+ foreign keys.
If the source and target models differ, the following fields are
generated: