Create a route to handle the deletion of the data. We do not need a template for this, as we can put the delete button wherever we like. Ensure to include an identifying variable (here we use cateogry_id) in order to query the correct record for deletion. Then do the delete -> save -> redirect pathway.
@app.route ("/delete_category/<int:category_id>")
def delete_category(category_id):
category = Category.query.get_or_404(category_id)
db.session.delete(category)
db.session.commit()
return redirect(url_for("categories"))