django get all object associated to a queryset code example Example: django filter on related field len(Collection.objects.filter(item__flag=True).distinct())