[Answered ]-Django: more complicated filter

1👍

Actually, this should do it:

B.objects.filter(a=mya, c__b__isnull=False)

or

B.objects.filter(a=mya, c__b=F('id'))

1👍

vals = C.objects.filter(b__a=mya).select_related("b").distinct()
bsiwant = [c.b for c in vals]

Should do it in a single query.

Leave a comment