summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFloris den Hengst <florisdenhengst@gmail.com>2015-03-07 18:45:57 +0100
committerTim Graham <timograham@gmail.com>2015-03-09 20:46:29 -0400
commit7a08c966ac45a77e6a41fc1cfa1bdbca02dcb1ff (patch)
tree2e4c8496cab0262470b77888a30586594c854d8b
parentee24ba26661d273e28a0a741ff0621c26e970c43 (diff)
[1.7.x] Fixed #24432 -- Added docs for ManyToManyFields that reside in and refer to the same model.
Backport of b9b8411129efe13642cef1fc6bbfc62bed717352 from master
-rw-r--r--docs/ref/models/fields.txt14
1 files changed, 13 insertions, 1 deletions
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index 73256acf17..e16008928b 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -1380,7 +1380,10 @@ 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:
+ created to hold the association. It has three fields to link the models.
+
+ If the source and target models differ, the following fields are
+ generated:
* ``id``: the primary key of the relation.
* ``<containing_model>_id``: the ``id`` of the model that declares the
@@ -1388,6 +1391,15 @@ that control how the relationship functions.
* ``<other_model>_id``: the ``id`` of the model that the
``ManyToManyField`` points to.
+ If the ``ManyToManyField`` points from and to the same model, the following
+ fields are generated:
+
+ * ``id``: the primary key of the relation.
+ * ``from_<model>_id``: the ``id`` of the instance which points at the
+ model (i.e. the source instance).
+ * ``to_<model>_id``: the ``id`` of the instance to which the relationship
+ points (i.e. the target model instance).
+
This class can be used to query associated records for a given model
instance like a normal model.