Advertisement
Pug_coder

Untitled

Sep 11th, 2023
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. class IndexListView(ListView):
  2. model = Post
  3. template_name = 'blog/index.html'
  4. queryset = Post.objects.prefetch_related(
  5. 'comments'
  6. ).select_related('author').filter(
  7. pub_date__lt=tz.now(),
  8. is_published=True,
  9. category__is_published=True,
  10. ).annotate(comment_count=Count('comments'))
  11.  
  12. ordering = '-pub_date'
  13. paginate_by = NUM_PAGES
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement