Rectangle 27 11

You can get your exact output by filtering the values you want to count, getting the list of values, and counting them, all in one set of database calls:

from django.db.models import Count
MyModel.objects.filter(myfield__in=('abc', 'xyz')).\

django most efficient way to count same field values in a query - Stac...

django django-models django-queryset