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

View file

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