【发布时间】:2017-09-05 22:45:11
【问题描述】:
我的烧瓶应用程序正在完美地使用 flask-wtf 表单收集数据。收藏后
@home.route('/add-new', methods=['POST', 'GET'])
def newlist():
return redirect( url_for('auth.login'))
form = ShoppingList()
if form.validate_on_submit():
#insert to list
item_id = len( shopping_lists ) + 1
shopping_list = ShoppingCart(session["email"], form.title.data, form.price.data,
form.quantity.data, item_id, form.description.data)
addToDic(session["email"], shopping_list)
result = shopping_lists
flash("List saved okay")
return render_template('home/dashboard.html', title="Dashboard", result = result)
#Render the dashboard template on the /dashboard route
return render_template('home/newlist.html',form=form, title="Add new")
我的问题是如何将结果 dic 打印到烧瓶模板中的表格中。这是模板代码
<h3>HOME</h3>
<p>{{ utils.flashed_messages() }}</p>
<table class="table table-bordered">
<thead>
<tr>
<th>Item name</th>
<th>price</th>
<th>quantity</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
</tr>
</tbody>
</table>
非常感谢。请联系
【问题讨论】:
标签: python-3.x dictionary flask wtforms