Open chgad opened 2 years ago
I came across the case where I wanted to query all Tags which have a certain property set on the related model like:
>>>Tag.objects.filter(food__is_vegetarian=True) [<Tag: salad>, <Tag: salad>, <Tag: fruit>, <Tag: fruit>]
which can be easily solved by the given example for the Food query here by adding the .distinct() call.
Food
.distinct()
Once you think about it, it is obvious but maybe we can just add it to be more explicit on this regard.
I came across the case where I wanted to query all Tags which have a certain property set on the related model like:
which can be easily solved by the given example for the
Food
query here by adding the.distinct()
call.Once you think about it, it is obvious but maybe we can just add it to be more explicit on this regard.