From 076ae33a617c5af785e2d3cd1c2d6396c73b9562 Mon Sep 17 00:00:00 2001 From: Naholiuk Yevhen Date: Wed, 27 Sep 2023 18:17:21 +0300 Subject: [PATCH] Fixed according to remarks --- taxi/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/taxi/views.py b/taxi/views.py index 66576acb..2ba0824d 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -14,13 +14,16 @@ def index(request): num_cars = Car.objects.count() num_manufacturers = Manufacturer.objects.count() - num_visits = request.session.setdefault("num_visits", 0) + if "num_visits" not in request.session: + request.session["num_visits"] = 0 + num_visits = request.session.get("num_visits", 0) + request.session["num_visits"] = num_visits + 1 context = { "num_drivers": num_drivers, "num_cars": num_cars, "num_manufacturers": num_manufacturers, - "num_visits": num_visits, + "num_visits": num_visits + 1, } return render(request, "taxi/index.html", context=context)