Well considering two models:
class School(models.Model):
name = TextField()
class Student(models.Model):
school = ForeignKey(School
related_name=students
)
firstname = TextField()
And the query:
School.objects.filter(Q(name="oldschool") & Q(
Q(students__firstname="hello") | Q(students__firstname="testname")
))
I retrieve the schools. However there is a join/subquery obviously executed, yet I do not get the student information. I also wish to get the student information for which the “first name is set”.
Can I make django orm actually fill in a students_set, so I do not have to do multiple lookups later? (having to iterate over the schools and check per school).