Hi,

I need to exclude certain elements from a QuerySet. My models look
like this (simplified):

class Author(models.Model):
        first_name = models.CharField(max_length=90, blank=True)
        last_name = models.CharField(max_length=90, blank=True)

class Page(models.Model):
        author = models.ForeignKey(Author)
        mother = models.ForeignKey('self', blank=True, null=True,
related_name='child_set')

For each author, I need to get the set of pages representing all top-
level works by that author (so I don't need the chapters, sections
etc.). I guess the solution looks something:

def _get_top_level_children(self):
        return self.page_set.exclude(author=mother.author)
top_level_children = property(_get_top_level_children)

Obviously, it does not work like this. How can I limit the queryset to
all entries where the 'author' object of a page does not match the
'author' object of the page's 'mother' object?

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to