On 4/13/06, Dave St.Germain <[EMAIL PROTECTED]> wrote:
Yup. The problem here is that Django assumes that if you have a ManyToMany field on self, then the relationship is symmetrical: for example:
class Person:
friend = ManyToManyField('self')
If I am your friend, then presumably you are my friend. To avoid confusion, the reverse representation of the relationship (person_set, or whatever related_name specifies) is not added to instances of Person.
Obviously, there are some use cases (such as yours) where this is not the case - to handle these, you need to set symmetrical=False:
insert_into = models.ManyToManyField('self',
null=True,
blank=True,
related_name='insert'
symmetrical=False)
This will add the related_name member on the related object, and will be a distinct set; adding to PressRun.insert_into is not the same as adding to PressRun.insert
Hope this helps,
Russ Magee %-)
I'm trying to create a model that relates back to itself with a ManyToManyField. Here's my model:
I'd like to use a simple ManyToMany, but the objects don't have a distinction between "inserted into" and "insert of".
Does that make sense?
Yup. The problem here is that Django assumes that if you have a ManyToMany field on self, then the relationship is symmetrical: for example:
class Person:
friend = ManyToManyField('self')
If I am your friend, then presumably you are my friend. To avoid confusion, the reverse representation of the relationship (person_set, or whatever related_name specifies) is not added to instances of Person.
Obviously, there are some use cases (such as yours) where this is not the case - to handle these, you need to set symmetrical=False:
insert_into = models.ManyToManyField('self',
null=True,
blank=True,
related_name='insert'
symmetrical=False)
This will add the related_name member on the related object, and will be a distinct set; adding to PressRun.insert_into is not the same as adding to PressRun.insert
Hope this helps,
Russ Magee %-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---