I am querying the DB to get a list of objects, and using annotate() to count how many associated Items they have with it.
I’d like to only return objects with an associated item count above 5.
lists = List.objects.exclude(picture_url='').exclude(picture_url__icontains='google').select_related('city','city__country', 'user', 'user__profile').annotate(items_added=Count('item'))[:10]
1 Answer