diff --git a/scipost_django/scipost/views.py b/scipost_django/scipost/views.py index 189a1b250a5922da5afb8302faf2b0fbe7b5b35d..83ea7fdcdb8f45c6f7183a27a11841476f006aaf 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)