1👍
✅
Specifying b__flag=...
will give you what you want.
A.objects.filter(b__flat=True)
Above could yield duplicated A
objects. Prevent that, use QuerySet.distinct
:
A.objects.filter(b__flat=True).distinct()
Source:stackexchange.com