title: "Bad Request The browser (or proxy) sent a request that this server could not understand." Flask login
body: <p>I am getting the ubiquitous flask wtform 400 error, and have tried other solutions. It let to improvement in my form, but didn't stop the error. I have</p>
  
  <p>templates/register.html:</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% block title %}Register{% endblock %}
  
  {% block content %}
      &lt;h2&gt; Welcome to the status page&lt;/h2&gt;
      &lt;br&gt;
      &lt;form action="/register" method="post" name="register_user"&gt;
          {{ form.hidden_tag() }}
          &lt;h4&gt;Register&lt;/h4&gt;
          &lt;p&gt;
              Email:&lt;br&gt;
              {{ form.email }}&lt;br&gt;
              {% for error in form.email.errors %}
                  &lt;p&gt;&lt;span style="color: red"&gt;[{{ error }}]&lt;/span&gt;&lt;/p&gt;
              {% endfor %}
              Password:&lt;br&gt;
              {{ form.password }}&lt;br&gt;
              {% for error in form.password.errors %}
                  &lt;p&gt;&lt;span style="color: red"&gt;[{{ error }}]&lt;/span&gt;&lt;/p&gt;
              {% endfor %}
              Confirm password:&lt;br&gt;
              {{ form.confirm }}&lt;br&gt;
              {% for error in form.confirm.errors %}
                  &lt;p&gt;&lt;span style="color: red"&gt;[{{ error }}]&lt;/span&gt;&lt;/p&gt;
              {% endfor %}
          &lt;/p&gt;
          &lt;p&gt;&lt;input type="submit" name="register" value="Submit"&gt;&lt;/p&gt;
      &lt;/form&gt;
      &lt;p&gt;&lt;a href="{{ url_for('login') }}"&gt;Log in&lt;/a&gt;&lt;/p&gt;
  
  &lt;script type="text/javascript"&gt; 
  
  &lt;/script&gt;
  
  {% endblock %}
  </code></pre>
  
  <p>forms.py:</p>
  
  <pre><code>from flask.ext.wtf import Form
  from wtforms import StringField, BooleanField, TextField, PasswordField, validators
  from wtforms.validators import Required
  
  
  class RegistrationForm(Form):
      # name = TextField('Your name', [validators.Length(min=2, max=60)])
      email = TextField('Email Address', [validators.Length(min=6, max=35)])
      password = PasswordField('New Password', [
          validators.Required(),
          validators.EqualTo('confirm', message='Passwords must match')
      ])
      confirm = PasswordField('Confirm Password')
  </code></pre>
  
  <p>the views.py:</p>
  
  <pre><code>    @application.route('/register', methods=['GET', 'POST'])
      def register():
          form = RegistrationForm(request.form)
          print(form)
          print(form.email.data)
          print(form.password.data)
          print(form.confirm.data)
          print(form.validate())
          if request.method == 'POST' and form.validate():
              user = User(email=form.email.data, password=form.password.data)
              user.save()
              flash('Thanks for registering')
              return redirect(url_for('awaiting_approval'))
          return render_template('register.html', form=form)
  </code></pre>
  
  <p>the prints look like</p>
  
  <pre><code>&lt;app.forms.RegistrationForm object at 0x7ff762e11790&gt;
  fakeguy@fake.org
  123456
  1234
  False
  </code></pre>
  
  <p>exactly like I expected. I assumed I would get a re-rendering of the page with an error message of 'Passwords must match' based on the validator of the <code>password</code> field. What can I do to let this form fail and rerender page? Thank you</p>