Let's say I have following models
class Foo(models.Model):
...
class Prop(models.Model):
...
class Bar(models.Model):
foo: models.ForeignKey(Foo, related_name='bars', ...)
prop: models.ForeignKey(Prop, ...)
Now I want to make the following query.
foos = Foo.objects.prefetch_related('bars__prop').all()
Does the above query makes 3 Database calls or only 2 (select_related for prop
from bar
), given that only one prop
is associated with bar
If it takes 3 calls then, is there a way to make it 2 calls by using selected_related for bar -> prop