diff --git a/games/templates/list_sessions.html b/games/templates/list_sessions.html index 90fa5ce..297c6ab 100644 --- a/games/templates/list_sessions.html +++ b/games/templates/list_sessions.html @@ -23,6 +23,7 @@ {% endif %} +{% if dataset.count != 0 %} @@ -73,4 +74,7 @@ {% endfor %}
+{% else %} +
No sessions found.
+{% endif %} {% endblock content %} diff --git a/games/views.py b/games/views.py index c6c1fe9..3054321 100644 --- a/games/views.py +++ b/games/views.py @@ -7,6 +7,7 @@ from django.http import HttpRequest, HttpResponse, HttpResponseRedirect from django.shortcuts import redirect, render from django.urls import reverse from django.utils import timezone +from django.core.exceptions import ObjectDoesNotExist from common.time import format_duration from common.utils import safe_division @@ -298,7 +299,10 @@ def list_sessions( context["total_duration"] = dataset.total_duration_formatted() context["dataset"] = dataset - context["last"] = Session.objects.latest() + try: + context["last"] = Session.objects.latest() + except ObjectDoesNotExist: + context["last"] = None return render(request, "list_sessions.html", context)