1def index(request):
2 ...
3
4 num_authors = Author.objects.count() # The 'all()' is implied by default.
5
6 # Number of visits to this view, as counted in the session variable.
7 num_visits = request.session.get('num_visits', 0)
8 request.session['num_visits'] = num_visits + 1
9
10 context = {
11 'num_books': num_books,
12 'num_instances': num_instances,
13 'num_instances_available': num_instances_available,
14 'num_authors': num_authors,
15 'num_visits': num_visits,
16 }
17
18 # Render the HTML template index.html with the data in the context variable.
19 return render(request, 'index.html', context=context)