Apologies for the difficult title, but I essentially have a model Foo that has multiple Bar objects (i.e. Foo.bar_set.all() gives me all the Bar objects). Also, each Bar object has multiple Baz objects in the same manner.
Is there any way to access all the Baz objects that belong to the Bar objects of Foo? Something like Foo.bar_set.all().baz_set.all() would be convenient…
As of now I’m just loading Foo.bar_set.all(), iterating through the bar‘s, and aggregating a set of foo‘s. Is there a better way to do this?
Maybe something like this? Here I’m assuming
Bazhas a fieldbarwhich is aForeignKeytoBar: