Updated: How to span multile tables in Django for a backwards relationship

Posted by ipartola on Stack Overflow See other posts from Stack Overflow or by ipartola
Published on 2010-06-14T23:46:03Z Indexed on 2010/06/15 22:32 UTC
Read the original article Hit count: 140

Filed under:
|

The Django documentation gives en example like so:

b = Blog.objects.get(id=1)
b.entry_set.all()

Which from what I understand results in 2 queries. What if I wanted to get the blog, the blog entries and all the comments associated with that entry in a number of queries that does not depend on the number of entries? Or do I have to drop down to SQL to do that?

© Stack Overflow or respective owner

Related posts about django

Related posts about django-models