При умножении веса на цену я получаю общую цену как умножение строки, но мне нужно целое число как общая цена
veiws.py:
def sell(request):
global Price
Metal = "Metal"
Steel = "Steel"
copper = "copper"
plastic = "plastic"
Aluminium = "Aluminium"
if request.method == "POST":
user = request.user
Scrap = request.POST.get('Scrap', '')
Weight = request.POST.get('Weight', '')
Address1 = request.POST.get('Address1', '')
Address2 = request.POST.get('Address2', '')
locality = request.POST.get('locality', '')
if Scrap.__eq__(Metal):
Price = 12
elif Scrap.__eq__(Steel):
Price = 10
elif Scrap.__eq__(copper):
Price = 6
elif Scrap.__eq__(plastic):
Price = 2
elif Scrap.__eq__(Aluminium):
Price = 30
x = Price
price = float(x)
Total_price = price * Weight
order = Orders(Scrap=Scrap, Total_Price=Total_price, Weight=Weight, Address1=Address1, Address2=Address2,
locality=locality, user=user)
order.save()
thank = True
id = order.order_id
return render(request, 'Main/sell.html', {'thank': thank, 'id': id})
return render(request, 'Main/sell.html',)
models.py
продажная форма
Я выбрал металл, цена которого 12, а вес я взял 12 кг, поэтому в качестве общей цены я должен получить 144

I тонкий клиент посылает weight в виде строки. Вы можете преобразовать ее в число.
Total_price = price * iny(Weight)

