title: Adding item to cart do not work properly after removing that same item from cart
body: <p>I am having a problem with adding item to cart after i delete same item from cart. When the item is added to cart and that item is deleted from cart, that same item does not display in cart when i try to add it again in cart. The item can only add in cart again when i delete it from the admin panel.</p>
  
  <p>Models.py:</p>
  
  <pre><code>class Item(models.Model):
      title = models.CharField(max_length=250)
      image = models.ImageField(null=True)
      price = models.IntegerField()
      old_price = models.IntegerField(null=True, blank=True)
      description = HTMLField()
      category = models.CharField(choices=CATEGORY_CHOICES, max_length=2)
      label = models.CharField(choices=LABEL_CHOICES, max_length=1)
      slug = AutoSlugField(populate_from='title')
      timestamp = models.DateTimeField(auto_now_add=True)
      active = models.BooleanField(default=True)
  
      class Meta:
          ordering = ['-timestamp']
          db_table = 'items'
          verbose_name_plural = 'Items'
  
      def __str__(self):
          return self.title
  
  class OrderItem(models.Model):
      user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
      ordered = models.BooleanField(default=False)
      item = models.ForeignKey(Item, on_delete=models.CASCADE)
      quantity = models.IntegerField(default=1)
      variation = models.ManyToManyField(Variation)
  
      def __str__(self):
          return f"{self.quantity} of {self.item.title}"
  
  class Order(models.Model):
      user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
      items = models.ManyToManyField(OrderItem)
      start_date = models.DateTimeField(auto_now_add=True)
      ordered_date = models.DateTimeField()
      ordered = models.BooleanField(default=False)
      billing_address = models.ForeignKey('BillingAddress', on_delete=models.SET_NULL, blank=True, null=True)
  
      def __str__(self):
          return self.user.username
  </code></pre>
  
  <p>Views.py:</p>
  
  <pre><code>@login_required 
  def add_to_cart(request, slug):
  
  item = get_object_or_404(Item, slug=slug)
  
  item_var = [] #item variation
  if request.method == 'POST':
      print(request.POST)
      qty = request.POST['quantity']
      for items in request.POST:
          key = items
          val = request.POST[key]
          print(key,val)
  
          try:
              v = Variation.objects.get(
                  item=item,
                  category__iexact=key,
                  title__iexact=val
              )
              item_var.append(v)
          except:
              pass
  
  order_item_qs = OrderItem.objects.filter(
      item=item,
      user=request.user,
      ordered=False
  )
  print(order_item_qs)
  
  if len(item_var) &gt; 0:
      for items in item_var:
          order_item_qs = order_item_qs.filter(
                      variation__exact=items,
                  )
  
  if order_item_qs.exists():
      order_item = order_item_qs.first()
      order_item.quantity = qty
      order_item.save()
      print(order_item_qs)
  
  else:
      order_item = OrderItem.objects.create(
          item=item,
          user=request.user,
          ordered=False
      )
      order_item.variation.add(*item_var)
      order_item.quantity = qty
      order_item.save()
      print(order_item)
  
      order_qs = Order.objects.filter(user=request.user, ordered=False)
      if order_qs.exists():
          order = order_qs[0]
          #check if the order item is in the order
          if not order.items.filter(item__id=order_item.id).exists():
              order.items.quantity = qty
              order.items.add(order_item)
              messages.info(request, "This item quantity was updated.")
              return redirect("shop:order-summary")
      else:
          ordered_date = timezone.now()
          order = Order.objects.create(user=request.user, ordered_date=ordered_date)
          order.items.add(order_item)
          messages.info(request, "This item was added to cart.")
  return redirect("shop:order-summary")
  
  @login_required 
  def remove_from_cart(request, slug):
  
      id = request.POST.get('id', None) #retrieve id
      print(id)
  
      item = get_object_or_404(Item, slug=slug) #if no item found raise page not found
      print(item)
  
      obj_order_qs = Order.objects.filter(
          user=request.user,
          ordered=False
      )
      if obj_order_qs.exists():
          order = obj_order_qs[0]
          if order.items.filter(item__slug=item.slug).exists():
              order_item = OrderItem.objects.filter(
                  id=id,
                  item=item,
                  user=request.user,
                  ordered=False
              )[0]
              order.items.remove(order_item)
              messages.info(request, "This item was removed from cart.")
              return redirect("shop:order-summary")
          else:
              messages.info(request, "This item was not in your cart.")
              return redirect("shop:order-summary")
      else:
          messages.info(request, "You do not have an active order.")
          return redirect("shop:order-summary")
  </code></pre>
  
  <p>Template:</p>
  
  <pre><code>&lt;form action="{{ order_item.item.get_remove_from_cart_url }}" method="post"&gt;
      {% csrf_token %}
      &lt;input name="id" type="hidden" value="{{ order_item.id }}" /&gt;
      &lt;input type="submit" value="Delete" /&gt;
  &lt;/form&gt;
  </code></pre>