15. POST method on cart
{% if sizes %}
<form method = "POST" action = "{% url 'add_to_cart' product.id %}"> <!--Forms in django need to specify its method, action (where it will be sent)-->
{% csrf_token %} <!--Protects (by generating a unique token) the forms from hackers trying to replicate it-->
<p>Select the size:</p>
{% for size in sizes %}
<input type="radio" name="size" value="{{ size }}"> <!--Radio button -> choose one option, all connected to the same name. Value is what is sent to the website-->
<label for= "{{ size }}">{{ size }}</label> <!--Button text, for tag vinculates each button the the size-->
{% endfor %}
<button type = "submit">Add to Cart</button> <!--Button type submit is used to send the form its in-->
</form>
{% endif %}

product_id is printed on the console.Last updated