[Answered ]-Django Many2Many query to find all `things` in a group of `categories`

1👍

Thing.objects.annotate(cat_count=Count('id', filter=Q(categories__in=[2, 3]))).\
        filter(cat_count__gte=2).values('id', 'cat_count')

Try it. cat_count__gte=2 because the two numbers are 2, 3.

Leave a comment