title: How to add Item to cart on ListView Django/
body: <p>I am making django app, adding items to cart in detail-view work fine but i struggle with implementation the same on ListView. What should I do? I get an error on ListView Post  - N<code>o Item matches the given query.</code></p>
  <p>views.py</p>
  <pre><code> class ShopListView(ListView):
          model = Item
          template_name =  'shop/home.html'
          context_object_name = 'items'
          def post(self, request, *args, **kwargs):
              pk = self.kwargs.get('pk')
              item = get_object_or_404(Item, id=pk)
              orderItem, created = OrderItem.objects.get_or_create(order_item=item)
              order, created = Order.objects.get_or_create(order_user=request.user)
              order.save()
              order.order_items.add(orderItem)
              return HttpResponse('Items added')
  </code></pre>
  <p>Also if i do post(self,request,pk) as in DetailView i get an error one argument is missing 'pk'.</p>
  <pre><code>class ShopDetailView(DetailView):
      model = Item 
      template_name = 'shop/detail.html'
      context_object_name = 'item'
  
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context['comments'] = Comment.objects.filter(item=self.object)
          context['form'] = CommentCreationForm()
          return context
  
      def post(self, request, pk):
          if 'buy' in request.POST:
              item = get_object_or_404(Item, id=pk)
              orderItem, created = OrderItem.objects.get_or_create(order_item=item)
              order, created = Order.objects.get_or_create(order_user=request.user)
              order.save()
              order.order_items.add(orderItem)
              return HttpResponse('Items added to the database')
          if 'comment' in request.POST:
              form = CommentCreationForm(request.POST)
              if form.is_valid():
                  comment = form.save(commit=False)
                  comment.comment_user = request.user
                  comment.item = Item.objects.get(id=pk)
                  comment.save()
                  return HttpResponse('post-created')
              else:
                  return HttpResponse('post not created')
  </code></pre>
  <p>DetailView works fine.</p>