|
List Info
Thread: Directional Many-to-many
|
|
| Directional Many-to-many |

|
2006-08-29 16:15:34 |
Hello,
Given this model:
class Person(models.Model):
name = models.CharField(maxlength=200)
children = models.ManyToManyField('self')
I can do:
FatherObj.children.add(ChildObj)
Somehow though, if I go to ChildObj and ask for its
children, I will
get the FatherObj as well. What am I doing wrong?
In my real example, the childObj can have many parent nodes,
thus
many-to-many is required.
Thanks,
Sia
--~--~---------~--~----~------------~-------~--~----~
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
django-users-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---
|
|
| Directional Many-to-many |

|
2006-08-29 17:23:25 |
|
| Take a look at: http://www.djangoproject.com/documentation/models/m2m_and_m2o/
Corey
On Aug 29, 2006, at 12:15 PM, Siah wrote:
Hello,
Given this model:
class Person(models.Model): name = models.CharField(maxlength=200) children = models.ManyToManyField('self')
I can do: FatherObj.children.add(ChildObj)
Somehow though, if I go to ChildObj and ask for its children, I will get the FatherObj as well. What am I doing wrong?
In my real example, the childObj can have many parent nodes, thus many-to-many is required.
Thanks, Sia
--~--~- --------~--~----~------------~-------~--~----~
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 django-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---
|
| Directional Many-to-many |

|
2006-08-30 00:17:08 |
|
On 8/30/06, Siah <gmail.com">siasookhteh gmail.com> wrote:
Somehow though, if I go to ChildObj and ask for its children, I will get the FatherObj as well. What am I doing wrong? By default, m2m fields are symmetrical - what you put in at one end, you can see from the other.
If you want to make m2m fields non-symmetrical, add symmetrical=False to your m2m definition. See
http://www.djangoproject.com/documentation/models/m2m_recursive/
for an example. Yours, 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 django-users-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---
|
[1-3]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|