-1
我的燒瓶應用程序正在使用flask-wtf形式完美地收集數據。收集後我需要幫助來打印對象的字典作爲html表格
@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>
非常感謝。請撥打