views:

40

answers:

1

Consider three django models: AA, BB and CC. AA has an M2M reference to BB and BB has an M2M reference to CC.

I have a single instance of AA. How do I execute a filter() QuerySet over the set of CC instances that are M2M related the the BB instances that are M2M related to that single AA instance?

+2  A: 

The following worked for me:

CC.objects.filter( bb__aa = aa_instance )

That produces a QuerySet you can further manipulate...

Found the answer in the django documentation here.

Jonathan