From 4077519d9ba237c805d79fab40271d7aa2a53f08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Caux?= <git@jscaux.org> Date: Fri, 29 Oct 2021 05:58:29 +0200 Subject: [PATCH] Solidify --- scipost_django/scipost/views.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scipost_django/scipost/views.py b/scipost_django/scipost/views.py index 189a1b250..83ea7fdcd 100644 --- a/scipost_django/scipost/views.py +++ b/scipost_django/scipost/views.py @@ -176,8 +176,12 @@ def index(request): def index2(request): """Homepage view of SciPost.""" + if NewsItem.objects.homepage().exists(): + latest_newsitem = NewsItem.objects.homepage().order_by('-date').first() + else: + latest_newsitem = NewsItem.objects.none() context = { - 'latest_newsitem': NewsItem.objects.homepage().order_by('-date').first(), + 'latest_newsitem': latest_newsitem } return render(request, 'scipost/index2.html', context) -- GitLab