diff options
| author | Nadège Michel <michel.nadege@gmail.com> | 2019-04-19 18:12:04 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-06-21 15:03:17 +0200 |
| commit | 87b1ad6e7351464c60e751b483d9dfce3a2d3382 (patch) | |
| tree | 24094846d09b2bc43429eb6c187c45b37a8bb2de /docs/ref | |
| parent | a9179ab032cda80801e7f67ef20db5ee60989f21 (diff) | |
Fixed #30421 -- Allowed symmetrical intermediate table for self-referential ManyToManyField.
Diffstat (limited to 'docs/ref')
| -rw-r--r-- | docs/ref/checks.txt | 2 | ||||
| -rw-r--r-- | docs/ref/models/fields.txt | 21 |
2 files changed, 16 insertions, 7 deletions
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt index a15eb558fe..1a388c6b37 100644 --- a/docs/ref/checks.txt +++ b/docs/ref/checks.txt @@ -222,7 +222,7 @@ Related fields * **fields.E331**: Field specifies a many-to-many relation through model ``<model>``, which has not been installed. * **fields.E332**: Many-to-many fields with intermediate tables must not be - symmetrical. + symmetrical. *This check appeared before Django 3.0.* * **fields.E333**: The model is used as an intermediate model by ``<model>``, but it has more than two foreign keys to ``<model>``, which is ambiguous. You must specify which two foreign keys Django should use via the diff --git a/docs/ref/models/fields.txt b/docs/ref/models/fields.txt index 7ca6b2c619..758c21c7bc 100644 --- a/docs/ref/models/fields.txt +++ b/docs/ref/models/fields.txt @@ -1537,6 +1537,11 @@ that control how the relationship functions. add the descriptor for the reverse relationship, allowing :class:`ManyToManyField` relationships to be non-symmetrical. + .. versionchanged:: 3.0 + + Specifying ``symmetrical=True`` for recursive many-to-many + relationships using an intermediary model was allowed. + .. attribute:: ManyToManyField.through Django will automatically generate a table to manage many-to-many @@ -1549,6 +1554,16 @@ that control how the relationship functions. :ref:`extra data with a many-to-many relationship <intermediary-manytomany>`. + .. note:: + + Recursive relationships using an intermediary model and defined as + symmetrical (that is, with :attr:`symmetrical=True + <ManyToManyField.symmetrical>`, which is the default) 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 + prefer Django not to create a backwards relation, set ``related_name`` + to ``'+'``. + 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. @@ -1624,12 +1639,6 @@ that control how the relationship functions. foreign keys to the model, or you want to explicitly specify which two Django should use. - Recursive relationships using an intermediary model are always defined as - non-symmetrical -- that is, with :attr:`symmetrical=False <ManyToManyField.symmetrical>` - -- therefore, there is the concept of a "source" and a "target". In that - case ``'field1'`` will be treated as the "source" of the relationship and - ``'field2'`` as the "target". - .. attribute:: ManyToManyField.db_table The name of the table to create for storing the many-to-many data. If this |
