[Fixed]-One to many with exclusions

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)

Leave a comment