title: object has no attribute 'object_list'
body: <p>I am getting an error and I think it may be for the same reasons Viktor had a problem (<a href="https://stackoverflow.com/questions/37675704/productlist-object-has-no-attribute-object-list">&#39;ProductList&#39; object has no attribute &#39;object_list&#39;</a>)</p>
  <p>On Viktors post AKS wrote -</p>
  <p>You might be getting the error on following line in get_context_data() of the super class:</p>
  <pre><code>queryset = kwargs.pop('object_list', self.object_list)
  </code></pre>
  <p>The get method of <code>BaseListView</code> sets the <code>object_list</code> on the view by calling the <code>get_queryset</code> method:</p>
  <pre><code>self.object_list = self.get_queryset()
  </code></pre>
  <p>But, in your case, you are calling <code>get_context_data()</code> in <code>get_queryset</code> method itself and at that time <code>object_list</code> is not set on the view.</p>
  <p>I reviewed my trace back and saw code that AKS had mentioned.</p>
  <pre><code>  File &quot;C:\Users\HP\Django Projects\EcommerceProject\products\views.py&quot;, line 48, in get_context_data
      context = super(ProductListView, self).get_context_data(*args, **kwargs)
    File &quot;c:\Users\HP\DJANGO~1\ECOMME~1\lib\site-packages\django\views\generic\list.py&quot;, line 131, in get_context_data
      queryset = kwargs.pop('object_list', self.object_list)
  AttributeError: 'ProductListView' object has no attribute 'object_list'
  [03/Aug/2020 18:20:21] &quot;GET /products/ HTTP/1.1&quot; 500 90906
  </code></pre>
  <p>Here is my code</p>
  <pre><code>class ProductListView(ListView):
      model = Product
      template_name = &quot;products/list.html&quot;
      # added for pagination
      context_object_name='object_list' #Default: object_list
      # print(context_object_name)
      # paginate_by = 3
  
  def get_context_data(self, *args, **kwargs):
      context = super(ProductListView, self).get_context_data(*args, **kwargs)
      cart_obj, new_obj = Cart.objects.new_or_get(self.request)
      print(&quot;get context data&quot;)
      # context = {}
      context['cart'] = cart_obj
      return context
  
  
  
  def get_queryset(self, *args, **kwargs):
      request = self.request
      return Product.objects.all()
  
  def get(self, request):
      
      paginate_by = request.GET.get('paginate_by',6) or 4
      data = self.model.objects.all()
      paginator = Paginator(data, paginate_by)
      page = request.GET.get('page')
     
      try:
          paginated = paginator.page(page)
      except PageNotAnInteger:
          paginated = paginator.page(1)
      except EmptyPage:
          paginated = paginator.page(paginator.num_pages)
  
      # context={}
      context = self.get_context_data()
      context['DataPaginated'] = paginated
      context['paginate_by'] = paginate_by
  
      # return render(request, self.template_name, {'DataPaginated':paginated, 'paginate_by':paginate_by, 'cart':cart_obj})
      return render(request, self.template_name, context)
  </code></pre>
  <p><strong>Issue Fixed</strong></p>
  <p>I slightly modified the <code>get_context_data</code> function in the class <code>ProductListView(ListView):</code></p>
  <pre><code>def get_context_data(self, *args, **kwargs):
      self.object_list = super().get_queryset()
      context = super(ProductListView, self).get_context_data(*args, **kwargs)
      
  </code></pre>