> We don't need the first query for fetching books. All data about book
> available from BookSequence too. And all filters you apply to books, you can
> apply to BookSequence via book__ filter. Again, from my first example, and
> using just one query
> bs =
> BookSequence.objects.filter(book__title__startswith='Hello').select_related()
> for s in bs:
> print s.sequence.name, s.number_in_sequence, s.book.title
That's right. But if we have a book that doesn't belong to any sequence,
bs will be *empty*.
--
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?hl=en.
No comments:
Post a Comment