title: How to write a POST method to an a tag in Django
body: <p>I am trying to write a POST method an "a" tag href but it is not working </p>
  
  <p>I was successful writing it in another page to select from an option but I am trying to implement it in an a href but it is not working</p>
  
  <pre><code>&lt;form method="POST" action="{{ item.get_add_to_cart_url }}"&gt;
  {% csrf_token %}
  &lt;a href="{% url 'core:add-to-cart' order_item.item.slug %}"&gt;&lt;i class="fas fa-plus ml-2"&gt;&lt;/a&gt;&lt;/i&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This is the HTML that I am trying to implement the same logic for which is working perfectly</p>
  
  <pre><code>                            {% csrf_token %}
                              &lt;input class="btn btn-primary btn-md my-2 p" type="submit" value="Add to cart"&gt;
  
                              {% if object.variation_set.all %}
  
                              {% if object.variation_set.sizes %}
                          &lt;select class="form-control" name="size"&gt;
                              {% for items in object.variation_set.sizes %}
                              &lt;option value="{{ items.title|lower }}"&gt;{{ items.title|capfirst }}&lt;/option&gt;
                              {% endfor %}                      
                          &lt;/select&gt;
                          {% endif %}
                          {% endif %}
  </code></pre>
  
  <p>This is the views:</p>
  
  <pre><code>
  @login_required
  def add_to_cart(request, slug):
      item = get_object_or_404(Item, slug=slug)
      order_item_qs = OrderItem.objects.filter(
          item=item,
          user=request.user,
          ordered=False
      )
      print(item)
      print(order_item_qs)
      item_var = []  # item variation
      if request.method == 'POST':
          for items in request.POST:
              key = items
              val = request.POST[key]
              try:
                  v = Variation.objects.get(
                      item=item,
                      category__iexact=key,
                      title__iexact=val
                  )
                  item_var.append(v)
              except:
                  pass
  
          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 += 1
          order_item.save()
      else:
          order_item = OrderItem.objects.create(
              item=item,
              user=request.user,
              ordered=False
          )
          order_item.variation.add(*item_var)
          order_item.save()
  
      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.add(order_item)
              messages.info(request, "This item quantity was updated.")
              return redirect("core: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("core:order-summary")
  </code></pre>
  
  <p>Is this the best way to use a Post method?</p>