mercredi 1 mars 2017

Flask : Method Not Allowed when delete item

I got error message 'Method Not Allowed' while I was working on delete method. What I wanted to do was when user click button, it sends a key which name is todo_id, and it delete item in database and redirects to the index.

This is views.py

@app.route('/delete_todo/<int:todo_id>', methods=['POST'])
@login_required
def delete_todo(todo_id):
    g.db.execute('''delete * from todo where todo_id = ?''', [todo_id])
    g.db.commit()
    flash('Your message was deleted')
    return redirect(url_for('index'))

This is template


    <small>None</small>
 




Aucun commentaire:

Enregistrer un commentaire