Flask WTForms Form Does Not Validate
I cannot get a certain simple Flask WTForm to validate. After a couple of days of struggle, I've tried everything I can think of. I'm new to Flask and Web programming in general. H
Solution 1:
Have you tried to insert a CSRF token in your HTML file?
For example, by adding the following to your Jinja template?
<body>
<div>
<form action="{{ url_for('newTest') }}" method="POST" name="add_rest">
<!-- Added line -->
{{ form.csrf_token }}
<ul>
<li>Name: {{ form.name }}</li>
<li>Address: {{ form.address }}</li>
</ul>
<input type="submit" value="Create">
</div>
</body>
This SO post may be useful.
You can also check the official documentation here which indicates that the validate()
function requires the use of a CSRF token.
Post a Comment for "Flask WTForms Form Does Not Validate"