From 0c3b6633bd068ac1d3a70fde9863f12462664471 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 25 Jul 2022 21:59:35 +0100 Subject: [PATCH] Allow there to be no blog posts for homepage --- website/home/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/home/models.py b/website/home/models.py index 6abfba7..cb9f4cf 100644 --- a/website/home/models.py +++ b/website/home/models.py @@ -25,6 +25,7 @@ class HomePage(BasePage): context["latest_blog_post"] = ( BlogPostPage.objects.live() # type:ignore[attr-defined] .defer_streamfields() - .latest("date") + .order_by("-date") + .first() ) return context