Inline select_related calls

This commit is contained in:
Jake Howard 2022-08-28 12:59:09 +01:00
parent 6403aca2a2
commit 735ab73ec0
Signed by: jake
GPG Key ID: 57AFB45680EDD477
2 changed files with 3 additions and 6 deletions

View File

@ -40,8 +40,7 @@ class BlogPostListPage(BaseListingPage):
return (
BlogPostPage.objects.descendant_of(self)
.live()
.select_related("hero_image")
.select_related("hero_unsplash_photo")
.select_related("hero_image", "hero_unsplash_photo")
.prefetch_related("tags")
.order_by("-date", "title")
)
@ -120,8 +119,7 @@ class BlogPostCollectionPage(BaseListingPage):
def get_listing_pages(self) -> models.QuerySet:
return (
BlogPostPage.objects.child_of(self)
.select_related("hero_image")
.select_related("hero_unsplash_photo")
.select_related("hero_image", "hero_unsplash_photo")
.prefetch_related("tags")
.order_by("-date", "title")
)

View File

@ -200,8 +200,7 @@ class BaseListingPage(RoutablePageMixin, BaseContentPage):
self.get_children()
.live()
.specific()
.select_related("hero_image")
.select_related("hero_unsplash_photo")
.select_related("hero_image", "hero_unsplash_photo")
.order_by("title")
)