1👍
Try this:
from django.db.models import Count
A.objects
.annotate(total_b=Count(child__id))
.annotate(excluded_b=Count(child__id__in=forbidden_list))
.exclude(total_b=excluded_b)
Source:stackexchange.com
1👍
Try this:
from django.db.models import Count
A.objects
.annotate(total_b=Count(child__id))
.annotate(excluded_b=Count(child__id__in=forbidden_list))
.exclude(total_b=excluded_b)