Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.19 KB | None | 0 0
  1. @register.simple_tag
  2. def get_most_commented_posts(count=5):
  3.     return Post.published.annotate(total_comments=Count('comments'))\
  4.                          .order_by('-total_comments')[:count]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement