title: Django Tutorial : What is get_queryset and why "model = poll" isn't needed?
body: <p>In Django Official Tutorial, "Generic views" are introduced.</p>
  
  <p>We have : </p>
  
  <pre><code>(...)
      class IndexView(generic.ListView):
          template_name = 'polls/index.html'
          context_object_name = 'latest_poll_list'
  
          def get_queryset(self):
              """Return the last five published polls."""
              return Poll.objects.order_by('-pub_date')[:5]
  
  
      class DetailView(generic.DetailView):
          model = Poll
          template_name = 'polls/detail.html'
  (...)
  </code></pre>
  
  <p>(URL : <a href="https://docs.djangoproject.com/en/1.6/intro/tutorial04/#amend-views" rel="nofollow">https://docs.djangoproject.com/en/1.6/intro/tutorial04/#amend-views</a>)</p>
  
  <p>And it says :</p>
  
  <blockquote>
    <p>Each generic view needs to know what model it will be acting upon.
    This is provided using the model attribute.</p>
  </blockquote>
  
  <p>1/ Then why don't we have <code>model = poll</code> in IndexView class as in DetailView class ?</p>
  
  <p>2/ The second -and maybe related- question is : what is <code>def get_queryset()</code> and why do we need it? Counldn't we do just do something like <code>queryset = Poll.objects.order_by('-pub_date')[:5]</code> (just as class atribute)?</p>