Skip to content

Commit

Permalink
Add comment to ArticlePageManager.get_queryset
Browse files Browse the repository at this point in the history
  • Loading branch information
psiemens committed Oct 25, 2023
1 parent 7e5b3d8 commit 75971a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions article/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,12 @@ class Meta:
class ArticlePageManager(PageManager):

def get_queryset(self):
"""
Extend the default queryset to prefetch featured images for all articles.
This significantly reduces the number of database queries on pages that list
a large number of articles.
"""
return super() \
.get_queryset() \
.prefetch_related('featured_media__image')
Expand Down

0 comments on commit 75971a4

Please sign in to comment.