Allow there to be no blog posts for homepage

This commit is contained in:
Jake Howard 2022-07-25 21:59:35 +01:00
parent f8d5cc5ba5
commit 0c3b6633bd
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -25,6 +25,7 @@ class HomePage(BasePage):
context["latest_blog_post"] = ( context["latest_blog_post"] = (
BlogPostPage.objects.live() # type:ignore[attr-defined] BlogPostPage.objects.live() # type:ignore[attr-defined]
.defer_streamfields() .defer_streamfields()
.latest("date") .order_by("-date")
.first()
) )
return context return context