I'm trying to let the page show person details with a button in the bottom to delete the person from the db and directs to home home page. The problem is that for some reason the delete method is not working..
@app.route('/venues/<int:venue_id>')
def show_venue(venue_id):
data = Venue.query.get(venue_id)
return render_template('pages/show_venue.html', venue=data)
@app.route('/venues/<int:venue_id>', methods=['DELETE'])
def delete_venue(venue_id):
try:
Venue.query.filter_by(id=venue_id).delete()
db.session.commit()
except Exception as e:
print(e)
error = True
db.session.rollback()
finally:
db.session.close()
if not error:
flash('Venue was successfully deleted!')
return render_template('pages/home.html')
else:
flash('An error occurred. Venue ' +
request.form['name'] + ' could not be deleted.')
return None
inside the HTML:
...
<form class="form" method="DELETE" action="/venues/{{venue.id}}">
<input type="submit" value="Delete Venue">
</form>
...
The console shows no errors but it literally does nothing.. just returns to the same page.. thanks for help