From 376beea02f1cc6a0f64fafd74eab6fbbc3ada4dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Sun, 19 Feb 2023 14:55:06 +0100 Subject: [PATCH] Fix error when generating charts with less than 2 entries --- games/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/games/views.py b/games/views.py index 6fbcc76..a11e5f9 100644 --- a/games/views.py +++ b/games/views.py @@ -156,7 +156,7 @@ def list_sessions( # cannot use dataset[0] here because that might be only partial QuerySet context["last"] = Session.objects.all().order_by("timestamp_start").last() # charts are always oldest->newest - if Session.objects.count() >= 2: + if dataset.count() >= 2: context["chart"] = playtime_over_time_chart(dataset.order_by("timestamp_start")) return render(request, "list_sessions.html", context)