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)