This is bound to be a duplicate question but I can't find any others. I'm trying to get a list of photos that have complaints. I can't simply get complaints and deal with the related photos - I need a queryset of photos.
This should work but doesn't seem right:
Photo.objects.filter(complaint__id__gte=0)
This doesn't seem like the most efficient way:
Photo.objects.annotate(Count('complaint')).exclude(complaint__count=0)
Is there a better way?