Custom SQL in QuerySet

1
2
3
4
5
6
7
Blog.objects.extra(
select={
'entry_count': 'SELECT COUNT(*) FROM blog_entry WHERE blog_entry.blog_id = blog_blog.id'
},
)
# blog_blog table come from standart query