get most repeated instance in a queryset django code example
Example: get most repeated instance in a queryset django
from django.db.models import Count
most_common = Post.objects.annotate(mc=Count('category')).order_by('-mc')[0].mc
from django.db.models import Count
most_common = Post.objects.annotate(mc=Count('category')).order_by('-mc')[0].mc