On 4/24/06, nevroe <[EMAIL PROTECTED]> wrote: > Thanks for the reply. I had previously tried to do a > ManyToMany("self") a few months ago, with no luck, so I figured it must > still be the case. Also, the "bug" for this is still open: > > http://code.djangoproject.com/ticket/75
Ok - I never knew about that ticket. > So, I quickly went in and tried this out, and unfortunately, it doesn't > solve the problem. The advantage in my original approach, an > intermediary class with two ForeignKeys, is that it has a sense of > directionality: it's an ordered graph. With ManyToMany, it's > unordered, and I'm not quite sure how I can store that directionality > anywhere. Sounds like you are looking for is the 'symmetrical' flag. By default, m2m to self relations are set up as symmetrical (so, if you have a person model, with a reference to self called friend, then if I am your friend, you are my friend). However, if you want to maintain directionality, you can specify symmetrical=False, and the database will keep the directionality. So, in your case, you would be looking for something like: class Node(models.Model): path = models.CharField(maxlength=255,unique=True) created_at = models.DateTimeField(null=True) targets = models.ManyToManyField("self", related_name="sources", symmetrical=False) You might be able to do something better with the field names, but I'll leave that as an exercise for the reader. If you want more details, check out the magic removal Model API docs (in the docs directory of a MR checkout). > Which brings up my original question -- is there any easy way to > translate a QuerySet on one node into a QuerySet on another (by use of > a ForeignKey field)? Not really. There are a few ways to do it with two queries (as you have noted elsewhere in this thread). Suggestions welcome on any way to extend Django query syntax to encompass this sort of transformation. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---