Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 210

My Add to cart button not calling out product id

$
0
0

In my product details page, I have an "Add to cart" button that is expected to bring out the product through the id on the next page.

This is my view function according to tutorial:

        def add_to_cart(request):        user = request.user        product_id = request.Get.get('prod_id')        product = Product.objects.get(id=product_id)        Cart(user=user, product=product).save()        return redirect("/cart")

In the product_details page, i have the form for the button as:

<form action="/add-to-cart" class="d-inline"><input type="hidden" name="prod_id" value={{product.id}}><button type="submit" class="btn btn-primary shadow px-5 py-2">                    Add to Cart</button></form>

Apparently, the name stores the value of the product with the specific id. I am trying to callout the product with the id in the function so it could be added to cart but it comes with an attribute error:'WSGIRequest' object has no attribute 'get'.My lecturer must have done something with this line:product_id = request.Get.get('prod_id')It worked for him in the tutorial.

please help.


Viewing all articles
Browse latest Browse all 210

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>