title: Add a cancel button in Flask with Flask-WTF/WTForms
body: <p>I would like to add a cancel button which goes back to previous page.
  My code is :
  forms.py:</p>
  <pre><code>from flask_wtf import Form
  from wtforms import StringField, HiddenField, SubmitField
  from wtforms.validators import DataRequired, Length, ValidationError
  
  
  def _required(form, field):
      if not field.raw_data or not field.raw_data[0]:
          raise ValidationError('Field is required')
  
  class OrganisationForm(Form):
      id = HiddenField('id', default=&quot;-1&quot;)
      name = StringField('name', validators=[DataRequired()])
      manager_name = StringField('manager_name')
      address = StringField('address', validators=[DataRequired()])
      city = StringField('city', validators=[DataRequired()])
      postal_code = StringField('postal_code', validators=[DataRequired(), Length(max=16)])
      province = StringField('province', validators=[Length(max=2, message=&quot;Can't exceed 2 characters&quot;)])
      country = StringField('country', validators=[DataRequired()])
      submit = SubmitField('Add')
      cancel = SubmitField('Cancel')
  </code></pre>
  <p>and template page:</p>
  <pre><code>{% block content %}
  &lt;div class=&quot;content-section&quot;&gt;
    {{ utils.flashed_messages() }}
    &lt;div class=&quot;center&quot;&gt;
  
        {% if add_orgnisation %}
                  &lt;h1&gt;add an organisation&lt;/h1&gt;
              {% else %}
                  &lt;h1&gt;Edit an organisation&lt;/h1&gt;
        {% endif %}
      &lt;br/&gt;
      &lt;br/&gt;
      {{ wtf.quick_form(form,novalidate=True) }}
    &lt;/div&gt;
  &lt;/div&gt;
  {% endblock %}
  </code></pre>
  <p>views,py</p>
  <pre><code>@orgs.route('/organisations/org_new')
  @login_required
  def org_new():
      add_orgnisation = True
      form = OrganisationForm()
      return render_template(&quot;organisations/organisation_form.html&quot;, form=form, title=&quot;New Organisation&quot;, edit=False, add_orgnisation=add_orgnisation)
  </code></pre>
  <p>I have a 405 error when I click on cancel button: Method not allowed.</p>
  <p>Where is my mistake? and what should I add to have a go back previous page when I click on Cancel?</p>
  <p>thanks</p>