I have two arrays sent with ajax from template. One array contains the product id and the second is the quantity. The problem is when I get the price of product per piece from database I must to multiply with the quantity.
How can I do price_product[ a, b, c,d] * quantity[30,50,40,70] => a*30, b*50 ....??
This is my current code
def price(request):
product = request.POST.getlist('product[]') #exemple product id ['1','3','5']
quantity = request.POST.getlist('quantity[]') #exemple quantity['30','50','6']
price_product = list(set(ListProduct.objects.filter(id__in=product).values_list('price_buc', flat=True)))
context = {
'data': price_product
}
return JsonResponse(context)