Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @register.simple_tag
- def get_most_commented_posts(count=5):
- return Post.published.annotate(total_comments=Count('comments'))\
- .order_by('-total_comments')[:count]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement