[Answered ]-Filter object and order by number of filters matched

1👍

You can annotate with the number of filtered Tag objects:

from django.db.models import Count

filtered = Post.objects.filter(
    tags__in=['thoughts', 'django', 'example']
).alias(
    ntags=Count('tags')
).order_by('-ntags')

Leave a comment