On 2 Sep., 23:14, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-09-02 at 13:12 -0700,janedenonewrote: > > Hi, > > > I am in the process of moving my handmade website to a Django-based > > version. One of my SQL queries returns all articles by a certain > > author if this article is not a chapter or section of an article by > > the same author: > > > SELECT pages.id, pages.author_id, motherpages.author_id AS > > motherauthor > > FROM pages, pages AS motherpages > > WHERE motherpages.page_id = pages.mother_id > > AND pages.author_id = 1234 > > AND pages.author_id <> motherpages.author_id > > It should be possible to get the same effect in Django, but exactly what > you write will depend upon your models. Perhaps you could construct a > small example of models that show the relations here (in Python). We > don't all 57 or whatever number of fields you have in each model. It > should be possible to write an example with only a field or two in each.
Thanks a lot: class Author(models.Model): id = models.IntegerField(primary_key=True) class Page(models.Model): id = models.IntegerField(primary_key=True) author = models.ForeignKey(Author) mother = models.ForeignKey('self', related_name='child_set') Kind regards, Jan --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---