Skip to content

Commit

Permalink
Prefetch the blog images on the landing page so we make fewer queries
Browse files Browse the repository at this point in the history
  • Loading branch information
haydngreatnews committed Jul 31, 2024
1 parent 1dfd398 commit f9689eb
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cdhweb/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ def get_context(self, request, year=None, month=None):
else:
posts = self.get_latest_posts()

posts = posts.prefetch_related("image", "image__renditions")

page_number = request.GET.get("page") or 1
paginator = Paginator(posts, self.page_size)
page = paginator.page(page_number)
Expand Down

0 comments on commit f9689eb

Please sign in to comment.