Imagine the following model:
class Parent(Model):
...
class Child(Model)
father = ForeignKey(Parent)
...
Some parents have children, others do not (they're not parents in the real meaning, it's just a fictional name).
I would like to make the following query: I want to list all the Parents, and if they have children, bring me the children too. That would be the equivalent of a left outer join to Child table, that is:
select * from app_parent left join app_child on child_father_id=parent_id
This way, when I invoke Parent.child_set in my template, I won't hit the database a gazillion times. Is there a way to do that? Thanks