From 5f00a0d480eebf1ed119f44d81f586e150a44439 Mon Sep 17 00:00:00 2001 From: "Claudio Maggioni (maggicl)" Date: Sat, 27 Jul 2019 11:38:32 +0200 Subject: [PATCH] Fix pagination bug in counts --- counter/views.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/counter/views.py b/counter/views.py index 1b57546..d0cd8c5 100644 --- a/counter/views.py +++ b/counter/views.py @@ -18,6 +18,7 @@ import json from django.core.serializers.json import DjangoJSONEncoder import csv from django.utils.encoding import smart_str +import math # https://stackoverflow.com/questions/5882405 def tofirstdayinisoweek(year, week): @@ -122,8 +123,8 @@ def arrow_count_list(request): counts = ArrowCount.objects.order_by('-date') \ .filter(user = request.user)[start:finish] - pageCount = ArrowCount.objects.filter(user = request.user).count() / \ - settings.ITEMS_PER_PAGE + pageCount = math.ceil(ArrowCount.objects.filter(user = request.user).count() / \ + settings.ITEMS_PER_PAGE) template = loader.get_template('counter/list.html') return HttpResponse(template.render({ 'counts': counts,