summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/ref/checks.txt4
-rw-r--r--docs/ref/models/fields.txt11
-rw-r--r--docs/topics/db/models.txt4
3 files changed, 11 insertions, 8 deletions
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index f7c2e721cb..98a6e00e73 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -94,7 +94,9 @@ Related Fields
* **fields.E334**: The model is used as an intermediate model by ``<model>``, but it has more than one foreign key from ``<model>``, which is ambiguous. You must specify which foreign key Django should use via the through_fields keyword argument.
* **fields.E335**: The model is used as an intermediate model by ``<model>``, but it has more than one foreign key to ``<model>``, which is ambiguous. You must specify which foreign key Django should use via the through_fields keyword argument.
* **fields.E336**: The model is used as an intermediary model by ``<model>``, but it does not have foreign key to ``<model>`` or ``<model>``.
-* **fields.E337**: The field is given an iterable for through_fields, which does not provide the names for both link fields that Django should use for the relation through <model>.
+* **fields.E337**: Field specifies ``through_fields`` but does not provide the names of the two link fields that should be used for the relation through ``<model>``.
+* **fields.E338**: The intermediary model ``<through model>`` has no field ``<field name>``.
+* **fields.E339**: ``<model>.<field name>`` is not a foreign key to ``<model>``.
Signals
~~~~~~~
diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt
index ab24dd7e66..39af0c64b0 100644
--- a/docs/ref/models/fields.txt
+++ b/docs/ref/models/fields.txt
@@ -1353,11 +1353,11 @@ that control how the relationship functions.
class Group(models.Model):
name = models.CharField(max_length=128)
- members = models.ManyToManyField(Person, through='Membership', through_fields=('person', 'group'))
+ members = models.ManyToManyField(Person, through='Membership', through_fields=('group', 'person'))
class Membership(models.Model):
- person = models.ForeignKey(Person)
group = models.ForeignKey(Group)
+ person = models.ForeignKey(Person)
inviter = models.ForeignKey(Person, related_name="membership_invites")
invite_reason = models.CharField(max_length=64)
@@ -1368,9 +1368,10 @@ that control how the relationship functions.
above.
``through_fields`` accepts a 2-tuple ``('field1', 'field2')``, where
- ``field1`` is the name of the foreign key to the target model (``person``
- in this case), and ``field2`` the name of the foreign key to the model the
- :class:`ManyToManyField` is defined on (``group`` in this case).
+ ``field1`` is the name of the foreign key to the model the
+ :class:`ManyToManyField` is defined on (``group`` in this case), and
+ ``field2`` the name of the foreign key to the target model (``person``
+ in this case).
When you have more than one foreign key on an intermediary model to any
(or even both) of the models participating in a many-to-many relationship,
diff --git a/docs/topics/db/models.txt b/docs/topics/db/models.txt
index 4caf9ad736..d5a700f62e 100644
--- a/docs/topics/db/models.txt
+++ b/docs/topics/db/models.txt
@@ -440,12 +440,12 @@ explicit declaration defines how the two models are related.
There are a few restrictions on the intermediate model:
* Your intermediate model must contain one - and *only* one - foreign key
- to the target model (this would be ``Person`` in our example), or you must
+ to the source model (this would be ``Group`` in our example), or you must
explicitly specify the foreign keys Django should use for the relationship
using :attr:`ManyToManyField.through_fields <ManyToManyField.through_fields>`.
If you have more than one foreign key and ``through_fields`` is not
specified, a validation error will be raised. A similar restriction applies
- to the foreign key to the source model (this would be ``Group`` in our
+ to the foreign key to the target model (this would be ``Person`` in our
example).
* For a model which has a many-to-many relationship to itself through an