hola tengo este codigo
Código Python:
Ver originaldef update_cart_batch(request):
if request.method == 'POST':
cart = Cart(request)
products = request.POST.getlist('product')
qtys = request.POST.getlist('qty')
if (len(products) > 0) and (len(qtys) > 0):
for i in range(len(products)):
product_id = int(products[i])
qty = int(qtys[i])
try:
product = CatalogProduct.objects.get(publish=True, id=product_id)
if qty >= 1 and product.qty >= qty :
updateCart(cart,product,qty)
#add flash message if the product dont have stock
except CatalogProduct.DoesNotExist:
pass
my_url = reverse("catalog_get_cart")
return HttpResponseRedirect(my_url)
y me gustaria traladarlo a un form y validarlo por alli los productos son una lista
Código Python:
Ver original<input name="product" type="hidden" value="{{ item.product.id }}">
<input name="qty" type="number" value="{{ item.quantity }}">