{% for comment in comment_list reversed %}
from django.db.models import Count posts = Post.objects.annotate(num_comments=Count('comment')).order_by('-num_comments')