[Answer]-Django using foreignKey to retrieve one attribute in a query

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()

Leave a comment