[Answered ]-How use filter in following case .

2👍

Something like this:

from django.db.models import Count
Post.objects.annotate(num_comments=Count('comment')).filter(num_comments__gt=5)

The method is described in the aggregation section of the docs.

👤wim

Leave a comment