mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
[3.1.x] Improved ManyToManyField.through docs.
Backport of e7fa8aff43 from master
This commit is contained in:
committed by
Mariusz Felisiak
parent
e63644d37b
commit
32e22f0531
@@ -1837,6 +1837,13 @@ that control how the relationship functions.
|
|||||||
:ref:`extra data with a many-to-many relationship
|
:ref:`extra data with a many-to-many relationship
|
||||||
<intermediary-manytomany>`.
|
<intermediary-manytomany>`.
|
||||||
|
|
||||||
|
.. 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::
|
.. note::
|
||||||
|
|
||||||
Recursive relationships using an intermediary model and defined as
|
Recursive relationships using an intermediary model and defined as
|
||||||
@@ -1870,7 +1877,9 @@ that control how the relationship functions.
|
|||||||
points (i.e. the target model instance).
|
points (i.e. the target model instance).
|
||||||
|
|
||||||
This class can be used to query associated records for a given model
|
This class can be used to query associated records for a given model
|
||||||
instance like a normal model.
|
instance like a normal model::
|
||||||
|
|
||||||
|
Model.m2mfield.through.objects.all()
|
||||||
|
|
||||||
.. attribute:: ManyToManyField.through_fields
|
.. attribute:: ManyToManyField.through_fields
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user