Use method="POST"
On Sun, Oct 25, 2020 at 1:11 AM waqar khan <kkwaqar007@gmail.com> wrote:
I have already write html file in form {% csrf_token %}but not workingHtml file:{% extends 'base.html' %}
{% block content %}
{% load cart %}
<!--body -->
<div class="container-fluid mt-3">
<div class="row">
<!--filters-->
<div class="col-lg-3 mx-auto">
<div class="list-group">
<a href="/" class="list-group-item list-group-item-action ">ALL Products</a>
{% for category in categories %}
<a href="/?category={{category.id}}" class="list-group-item list-group-item-action ">{{category.name}}</a>
{% endfor %}
</div>
</div>
<!-- all products-->
<div id="products" class="col-lg-9 mx-auto">
<div class="row mx-auto">
{% for product in products %}
<div class="card mx-auto mb-3" style="width: 18rem;">
<img src="{{product.image.url}}" class="card-img-top" alt="...">
<div class="card-body">
<p class="card-title">{{product.name}}</p>
<p class="card-text"><b>{{product.price}}</b></p>
{{ product|is_in_cart:request.session.cart }}
</div>
<div class="card-footer p-0 no-gutters">
{% if product|is_in_cart:request.session.cart %}
<div class="row no-gutters" >
<form action="/" method="post" class="col-2">
{% csrf_token %}
<input hidden type="text" value="{{product.id}}" name="product">
<input hidden type="text" name="remove" value="True">
<input type="submit" value="-" class="btn btn-block btn-light border-right">
</form>
<div class="text-center col">{{product|cart_quantity:request.session.cart}} in Cart</div>
<form action="/" method="post" class="col-2">
{% csrf_token %}
<input hidden type="text" value="{{product.id}}" name="product">
<input type="submit" value="+" class="btn btn-block btn-light border-left">
</form>
</div>
{% else %}
<form action="/" method="POST" class="btn-block">
{% csrf_token %}
<input hidden type="text" value="{{product.id}}" name="product">
<input class="float-right btn btn-light form-control" type="submit" value="Add To Cart">
</form>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
</div>
{% endblock content %}problems--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ab1f6e7d-2798-4ec0-adeb-09f97a4bb727n%40googlegroups.com.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOhYkiz0-qzDAuSjj4WpyQhjTf%3D%3DZeHOYAzM%2BWHHLcnmMM%3Dfag%40mail.gmail.com.
No comments:
Post a Comment