【发布时间】:2013-11-04 11:20:24
【问题描述】:
我正在遍历购物车项目,并希望将数量与单价相乘,如下所示:
{% for cart_item in cart.cartitem_set.all %}
{{cart_item.quantity}}*{{cart_item.unit_price}}
{% endfor %}
有可能做这样的事情吗?任何其他方式来做到这一点!谢谢
【问题讨论】:
-
这是过滤器的巧妙使用。我没想过使用
cart_item.quantity作为value和cart_item.unit_price作为arg
标签: python django django-templates