我有一个网格,其中包含用户信息以及每行中一个名为“删除”的按钮。 我正在尝试单击按钮
从该网格中删除用户我为此目的创建了一条路线
@app.route('/delete_user/<email>', methods=['POST','GET'])
def delete_user(email):
table=db.users
query=table.remove( {'email': email} )
return render_template("index.html")
在我的模板(index.html)文件中 我已经完成了
{% for us in users %}
<tr>
<td>{{us['name']}}</td>
<td>{{us['email']}}</td>
<td><button type="button" onclick="url_for('delete_user',email={{us['email']}})" class="btn btn-primary btn-xs" data-title="Edit" data-toggle="modal" data-target="#edit" ><span class="glyphicon glyphicon-pencil"></span></button></td>
</tr>
{% endfor %}
但是它不起作用。 还有其他方法可以实现此功能吗?
答案 0 :(得分:1)
尝试
onclick="window.location.href='{{ url_for( 'delete_user',email=us['email']) }}