flask-wtforms

Flask view shows 400 error instead of template with form

浪子不回头ぞ 提交于 2019-11-26 08:37:47
问题 I\'m trying to display a page with a form, then add a Player to the database when the form is submitted. However, I can\'t view the form because the browser always shows a 400 Bad Request error. Other posts indicate that this could be because the name of the form input doesn\'t match the key I get from request.form , but all my keys match. Why do I get this error? <form method=\"post\"> {{ form.hidden_tag() }} <input name=\"name\"> <input name=\"available\"> <input type=\"submit\"> </form>

Multiple forms in a single page using flask and WTForms

我只是一个虾纸丫 提交于 2019-11-26 03:04:43
问题 I have multiple form on the same page that send post request to same handler in flask. I am generating forms using wtforms. what is the best way to identify which form is submitted ? I am currently using action=\"?form=oneform\" . I think there should be some better method to achieve the same? 回答1: I've been using a combination of two flask snippets. The first adds a prefix to a form and then you check for the prefix with validate_on_submit(). I use also Louis Roché's template to determine