1👍
✅
You can filter with:
Category.objects.filter(product__user=myuser).distinct()
where myuser
is the user you want to filter on.
The .distinct(…)
[Django-doc] will prevent returning the same Category
that many times as there are Product
s for that user.
Source:stackexchange.com