<form method="post" action="" class="w-full">
{% csrf_token %}
Quantity:
Add to cart
[View cart]()
class Cart(models.Model):
cart_id = models.CharField(primary_key=True)
total = models.DecimalField(max_digits=9, decimal_places=2)
quantity = models.IntegerField()
user = models.OneToOneField(User,on_delete=models.CASCADE)
class CartItem(models.Model):
cart = models.ForeignKey(Cart, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
quantity = models.IntegerField(default=0)
user = models.OneToOneField(User,on_delete=models.CASCADE)
this is my models.py and detail.html, how to perform view when add to cart button clicks or use do i need to use request.method
- List item