开发者

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

开发者 https://www.devze.com 2023-01-03 16:29 出处:网络
The Django documentation gives en ex开发者_Go百科ample like so: b = Blog.objects.get(id=1) b.entry_set.all()

The Django documentation gives en ex开发者_Go百科ample 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?


Blog.objects.select_related(...).get(id=1)


Seems that Django at this point does not support this feature.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号