【发布时间】:2014-03-29 00:50:14
【问题描述】:
我正在用 django 编写一个项目。 我正在将带有数量和天数的租赁产品添加到我的购物车中。
这是我的代码。 “addToCart.py”下的那些代码
pid=request.urlparams[0] #pid is a product id
cart = request.session.get('cart',{}) #create a cart
cart2[pid]= [days,quantity] # days, quantity are sent in using forms
“CheckOut.py”下的那些代码。现在我要计算总数。
product = product.objects.get(id=pid) # get the product
quantity=int(cart2[(str(pid)][1]) # this does not work. I need some help about how to do int and string coversion
total=product.Price*quantity*int(cart2[(str(pid)][0]) # this does not neither.
【问题讨论】:
-
你的意思是它不起作用。收到任何异常消息?
-
this does not work.不是一个有效的问题。不工作怎么办?你期待发生什么?实际发生了什么?输入是什么?您是否收到错误消息?如果是这样,它是什么?请提供完整的追溯。
标签: python django string integer type-conversion