Skip to content

Commit

Permalink
Fixed according to remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
grungezz committed Sep 27, 2023
1 parent 5db58c7 commit 076ae33
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions taxi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 076ae33

Please sign in to comment.