#32310: ManyToManyField.through docs clarification
------------------------------------------------+------------------------
               Reporter:  Fabio Sangiovanni     |          Owner:  nobody
                   Type:  Cleanup/optimization  |         Status:  new
              Component:  Documentation         |        Version:  master
               Severity:  Normal                |       Keywords:
           Triage Stage:  Unreviewed            |      Has patch:  0
    Needs documentation:  0                     |    Needs tests:  0
Patch needs improvement:  0                     |  Easy pickings:  0
                  UI/UX:  0                     |
------------------------------------------------+------------------------
 Hello and happy new year everyone!

 A note in the current `ManyToManyField.through` docs
 
(https://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ManyToManyField.through)
 suggests that:

 > Recursive relationships using an intermediary model and defined as
 symmetrical (that is, with symmetrical=True, which is the default) can’t
 determine the reverse accessors names, as they would be the same.

 But the value of the `symmetrical` argument seems irrelevant in this
 regard, since in both cases (`True` or `False` value) the system checks
 framework raises the same error (`fields.E304`).

 Repro:


 {{{
 from django.db import models


 class Relationship(models.Model):
     person1 = models.ForeignKey('Person', on_delete=models.CASCADE)
     person2 = models.ForeignKey('Person', on_delete=models.CASCADE)


 class Person(models.Model):
     other = models.ManyToManyField('self', through=Relationship,
 symmetrical=False)
 }}}

 `manage.py makemigrations` yields:

 {{{
 SystemCheckError: System check identified some issues:

 ERRORS:
 app.Relationship.person1: (fields.E304) Reverse accessor for
 'Relationship.person1' clashes with reverse accessor for
 'Relationship.person2'.
         HINT: Add or change a related_name argument to the definition for
 'Relationship.person1' or 'Relationship.person2'.
 app.Relationship.person2: (fields.E304) Reverse accessor for
 'Relationship.person2' clashes with reverse accessor for
 'Relationship.person1'.
         HINT: Add or change a related_name argument to the definition for
 'Relationship.person2' or 'Relationship.person1'.
 }}}

 for both values of the `symmetrical` argument of `ManyToManyField`.


 Am I missing something?

 Thanks!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32310>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.8f6ad7b9d1355f4b183d32ed0a6e8dab%40djangoproject.com.

Reply via email to