[Django]-Filtering based on .count() of a forgein key field in Django querysets

5👍

from django.db.models import Count
Type.objects.annotate(component_count=Count('component')).exclude(component_count=0)

Leave a comment