Given a queryset, I add the count of related objects (ModelA) with the following:
qs = User.objets.all() qs.annotate(modela__count=models.Count(\'modela\'))
You can simply filter before you annotate:
from django.db.models import Q, Count qs = ModelA.objects.filter(account__prop1__isnull=False).annotate(account_count=Count('account'))