#2653: multiple manytomanyfield on self causes complaint in manage.py
----------------------------------+-----------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: adrian
Type: defect | Status: new
Priority: normal | Milestone:
Component: Core framework | Version: SVN
Severity: normal | Keywords:
----------------------------------+-----------------------------------------
Consider:
{{{
#!python
class Foo(models.Model):
related = models.ManyToManyField('self')
suggestions = models.ManyToManyField('self')
}}}
Both relations should be symmetrical. If A suggests B, B suggests A (for
this code
base anyways).
What I expected to happen is adding B to A would add A to B. Instead I
get:
app.foo: Accessor for m2m field 'menu_suggestions' clashes with related
m2m field 'Foo.foo_set'. Add a related_name argument to the definition
for 'suggestions'.
app.foo: Accessor for m2m field 'related' clashes with related m2m field
'Foo.foo_set'. Add a related_name argument to the definition for
'related'.
Doesn't matter whether I set symmetrical to false or true.
The confusion stems from model-api.txt which states:
{{{
``symmetrical`` Only used in the definition of ManyToManyFields on self.
Consider the following model:
class Person(models.Model):
friends = models.ManyToManyField("self")
When Django processes this model, it identifies that it has
a ``ManyToManyField`` on itself, and as a result, it
doesn't add a ``person_set`` attribute to the ``Person``
class. Instead, the ``ManyToManyField`` is assumed to be
symmetrical -- that is, if I am your friend, then you are
my friend.
If you do not want symmetry in ``ManyToMany`` relationships
with ``self``, set ``symmetrical`` to ``False``. This will
force Django to add the descriptor for the reverse
relationship, allowing ``ManyToMany`` relationships to be
non-symmetrical.
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/2653>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---