title: Django tutorial. Generic views. context_object_name = 'latest_question_list'
body: <p>I'm a bit confused with Django generic views. As shown in <a href="https://docs.djangoproject.com/en/2.2/intro/tutorial04/#amend-views" rel="nofollow noreferrer">here</a> we are converting custom views into generic views. And while I understand what happens in DetailView and ResultsView, I don't entirely grasp how this: </p>
  
  <pre><code>def index(request):
      latest_question_list = Question.objects.order_by('-pub_date')[:5]
      template = loader.get_template('polls/index.html')
      context = {
          'latest_question_list': latest_question_list,
      }
      return render(request, 'polls/index.html', context)
  </code></pre>
  
  <p>converts into this:</p>
  
  <pre><code>class IndexView(generic.ListView):
      template_name = 'polls/index.html'
      context_object_name = 'latest_question_list'
  
      def get_queryset(self):
          """Return the last five published questions."""
          return Question.objects.order_by('-pub_date')[:5]
  </code></pre>
  
  <ol>
  <li>In the first example, <code>latest_question_list = Question.objects.order_by('-pub_date')[:5]</code></li>
  <li>But in the second example, what <code>latest_question_list</code> variable is equal to in here? We haven't even defined it..</li>
  </ol>
  
  <p>Can anyone please shed some light into this?</p>