title: Multiple forms with Flask keeps saying I haven't defined forms
body: <p>I am trying to set up two different forms on the same Flask page with validators, but it keeps telling me my forms are not defined. I get error:</p>
  
  <p>The code is designed to allow users to input a number and check if it is abundant, perfect, or deficient, and then with a separate form to allow users to define a range and get how many abundant, perfect or deficient numbers there are within that range.</p>
  
  <p>My code is as follows:</p>
  
  <pre><code>from flask import Flask, render_template, request
  from flask_wtf import Form
  from wtforms import IntegerField
  from wtforms.validators import InputRequired
  from perfect_numbers import classify, listInRange
  
  app = Flask(__name__)
  app.config['SECRET_KEY'] = 'DontTellAnyone'
  
  class PerfectForm(Form):
      inputNumber = IntegerField('input a number', default=1, validators=[InputRequired(message='Please input an integer')])
  
  class PerfectRangeForm(Form):
      startNumber = IntegerField('input a number', default=1, validators=[InputRequired(message='Please input an integer')])
      endNumber = IntegerField('input a number', default=1, validators=[InputRequired(message='Please input an integer')])
  
  @app.route('/', methods=['GET', 'POST'])
  def index():
      form1 = PerfectForm(request.form, prefix="form1")
      num = 1
      Classify = classify(num)
      if form.validate_on_submit() and form.data:
          num = request.form1['inputNumber']
          Classify = classify(form1.inputNumber.data)
          return render_template('index.html', form1=form1, num=num, classify=Classify)
      return render_template('index.html', num=1, form1=form1, classify=Classify)
  
  @app.route('/aliRange', methods=['GET', 'POST'])
  def aliRange():
      form2 = PerfectRangeForm(request.form2, prefix="form2")
      startNumber = 1
      endNumber = 1
      aliquot = 'abundant'
      Classify = classify(num)
      ListInRange = listInRange(startNumber, endNumber, aliquot)
      if form2.validate_on_submit() and form2.data:
          startNumber = request.form2['startNumber']
          endNumber = request.form2['endNumber']
          aliquot = request.form2['aliquot']
          ListInRange = listInRange(startNumber, endNumber, aliquot)
          return render_template('index.html', form2=form2, startNumber=startNumber, endNumber=endNumber, ListInRange=listInRange)
      return render_template('index.html', form2=form2, startNumber=startNumber, endNumber=endNumber, ListInRange=listInRange)
  
  if __name__ == '__main__':
      app.run(debug=True)
  </code></pre>
  
  <p>index.html:</p>
  
  <pre><code>{% from "_formhelpers.html" import render_field %}
  &lt;html lang="en" dir="ltr"&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;WTForms&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div&gt;
        &lt;form action="/" method="POST"&gt;
          &lt;dl&gt;
            {% if form1 %}
            {{ form1.csrf_token }}
            {{ render_field(form1.inputNumber) }}
            {% endif %}
            &lt;input type="submit" value="submit1"&gt;
          &lt;/dl&gt;
        &lt;/form&gt;
      &lt;/div&gt;
      &lt;div&gt;
        {{ num }} is {{ classify }}
      &lt;/div&gt;
  
      &lt;div&gt;&lt;/div&gt;
  
  &lt;div&gt;
    &lt;form action="/aliRange" method="POST"&gt;
      &lt;div class="form-group"&gt;
        &lt;p&gt;Input a start number and an end number to return a list of...&lt;/p&gt;
        &lt;select class="form-control" action="/aliRange" name="aliquot" method="POST"&gt;
          &lt;option value = 'abundant'&gt;Abundant&lt;/option&gt;
          &lt;option value = 'perfect'&gt;Perfect&lt;/option&gt;
          &lt;option value = 'deficient'&gt;Deficient&lt;/option&gt;
        &lt;/select&gt;
        &lt;p&gt;...numbers within that range&lt;/p&gt;
        &lt;form action="/aliRange" method="POST"&gt;
          &lt;dl&gt;
            {% if form2 %}
            {{ form2.csrf_token }}
            {{ render_field(form2.startNumber) }}
            {{ render_field(form2.endNumber) }}
            {% endif %}
            &lt;input class="btn btn-primary" type="submit" value="submit"&gt;
          &lt;/dl&gt;
        &lt;/form&gt;
      &lt;/div&gt;
  
    &lt;/form&gt;
    The {{ aliquot }} numbers between {{ startNumber }} and {{ endNumber }} are:
    {{ listInRange }}
  &lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Error I get atm is: AttributeError: 'Request' object has no attribute 'form1'</p>