所以我试图在我添加的篮子中显示该项目,但没有显示任何内容。
@phones.route("/cartt")
def shopping_cart():
total_price = 0
if "cart" not in session:
flash("There is nothing in your cart.")
return render_template("phones/cart.html", display_cart = {}, total = 0)
else:
items = [j for i in session["cart"] for j in i]
dict_of_phones = {}
phone_by_id = None
for item in items:
phone = get_phone_by_id(item)
print(phone.id)
total_price += phone.price
dict_of_phones = phone
return render_template('phones/cart.html', display_cart = dict_of_phones, total = total_price)
html:
{% for phone in dict_of_phones %}
<tr>
<td>{{phone.model}}</td>
<td>{{phone.year}}</td>
<td>${{ "%.2f" % phone.price}}</td>
<td>${{ "%.2f" % phone.price}}</td></tr>
{% endfor %}
白板的微信
森栏
相关分类