Reputation: 77
I have grid which users information and a button called Delete in each row. I am trying to delete user from that grid on button click
I have created a route for this purpose
@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")
And in my template (index.html) file I have done this
{% 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 %}
But It does not work. Is there any other to achieve this functionality?
Upvotes: 1
Views: 90
Reputation: 580
Try this
onclick="window.location.href='{{ url_for( 'delete_user',email=us['email']) }}
Upvotes: 1