These two pieces of code are identical at the first blush:
class IndexView(generic.ListView):
    template_name = 'polls/index.html'
    context_object_name = 'latest_poll_list'
    queryset = Poll.active.order_by('-pub_date')[:5]
and
class IndexView(generic.ListView):
    template_name = 'polls/index.html'
    context_object_name = 'latest_poll_list'
    def get_queryset(self):
        return Poll.active.order_by('-pub_date')[:5]
Is there any difference between them? And if it is:
What approach is better? Or when setting queryset variable is better than override the get_queryset method? And vice versa.
 
     
     
     
     
    