Skip to content

Commit

Permalink
'Solution'
Browse files Browse the repository at this point in the history
  • Loading branch information
Julia15031988 committed Dec 1, 2024
1 parent e4d52bc commit 873df7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions taxi/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

def index(request):
"""View function for the home page of the site."""
num_visits = request.session.get("num_visits", 0)
request.session["num_visits"] = num_visits + 1


num_drivers = Driver.objects.count()
num_cars = Car.objects.count()
Expand All @@ -15,6 +18,7 @@ def index(request):
"num_drivers": num_drivers,
"num_cars": num_cars,
"num_manufacturers": num_manufacturers,
"num_visits": num_visits,
}

return render(request, "taxi/index.html", context=context)
Expand Down
1 change: 1 addition & 0 deletions templates/taxi/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ <h2>Dynamic content</h2>
<li><strong>Cars:</strong> {{ num_cars }}</li>
<li><strong>Drivers:</strong> {{ num_drivers }}</li>
<li><strong>Manufacturers:</strong> {{ num_manufacturers }}</li>
<li><strong>You have visited this page</strong>{{ num_visits }} times.</li>
</ul>
{% endblock %}

0 comments on commit 873df7b

Please sign in to comment.