diff --git a/taxi/views.py b/taxi/views.py index 82ad312f..7301cdf2 100644 --- a/taxi/views.py +++ b/taxi/views.py @@ -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() @@ -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) diff --git a/templates/taxi/index.html b/templates/taxi/index.html index 13c59aa8..a5a42235 100644 --- a/templates/taxi/index.html +++ b/templates/taxi/index.html @@ -9,5 +9,6 @@

Dynamic content

  • Cars: {{ num_cars }}
  • Drivers: {{ num_drivers }}
  • Manufacturers: {{ num_manufacturers }}
  • +
  • You have visited this page{{ num_visits }} times.
  • {% endblock %}