[Answered ]-Filter a Django ManyToManyField by a multiple intersection with another ManyToManyField

2👍

✅

Is this what you need?

from django.db.models import Count

options = Option.objects.filter(tags__in=entry.tags.all())
options = options.annotate(tag_count=Count('tags'))
options = options.filter(tag_count__gte=2)

Leave a comment