Since my_book.auther_set.all() returns a QS, can't you just say
something like ...all().filter(author__isalive=True) or something like
that?  I've never tried, but I thought that django would figure it
out?

J

On Aug 25, 12:11 am, MrJogo <[EMAIL PROTECTED]> wrote:
> How do I create a custom manager for many-to-many traversal? An
> example will illustrate what I want to do better. Suppose I have the
> following models.py:
>
> class Book(models.Model):
>   title = models.CharField(max_length=100)
>
> class Author(models.Model):
>   books = models.ForeignKey(Book)
>   name = models.CharField(max_length=100)
>   is_alive = models.BooleanField()
>
> This is a many-to-many relationship: a book can have multiple authors
> and an author can have written multiple books.
>
> If I have a book object my_book, and I want to get all the authors, I
> do my_book.author_set.all(). How can I set up a custom manager to only
> get living authors of that book, so I could do something like
> my_book.livingauthor_set.all()?
>
> Thanks
--~--~---------~--~----~------------~-------~--~----~
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