title: How to solve the form is undefined , Flask?
body: <p>I have two routes inside my application, if i want to access the second one i got this error:</p>
  
  <p><code>UndefinedError: 'register_form' is undefined</code></p>
  
  <p>The <strong>register_form</strong> is for the first route, here is the <strong>first route</strong>:</p>
  
  <pre><code>@abonent_route.route('/')
  @abonent_route.route('/', methods=['GET', 'POST'])
  def index():
  
      register_form = RegistrationForm()
      return render_template('index.html', register_form=register_form)
  </code></pre>
  
  <p>This is the <strong>second route</strong>:</p>
  
  <pre><code>@client_route.route('/client/')
  @client_route.route('/client/', methods=['GET', 'POST'])
  def index():
      form_login = ClientLogin()
      return render_template('index.html', form_login=form_login)
  </code></pre>
  
  <p>Also I've initialized the routes inside my <strong>create_app</strong> function as following:</p>
  
  <pre><code>from .abonent import abonent_route
  app.register_blueprint(abonent_route)
  
  from .client import client_route
  app.register_blueprint(client_route)
  </code></pre>
  
  <p>Now the problem is if i replaced the <strong>client route</strong> step up so to be above the <strong>abonent route</strong> and if i open <strong>abonent route</strong>, i got the same error but a little bit different:</p>
  
  <p><code>UndefinedError: 'form_login' is undefined</code></p>
  
  <p>This time, the <strong>form_login is undefined</strong>, also if i again moved the abonent back again to it place and if i want to visit the <strong>client route</strong>, i got the first error which is <strong>register_form undefined</strong> .</p>
  
  <p>Please any help would be appreciated .</p>
  
  <p><strong>Edit: Add some codes</strong></p>
  
  <p><code>Client main route</code>:</p>
  
  <pre><code>@client_route.route('/client/', methods=['GET', 'POST'])
  def index():
      form_login = ClientLogin()
      if request.method == 'GET' and request.args.get('next'):
          session['next'] = request.args.get('next')
  
      if form_login.validate_on_submit():
          user = Client.query.filter_by(
              tele = form_login.telephone.data
          ).first()
          if user:
              if check_password_hash(user.password, form_login.password.data):
                  session['client_logged_in'] = user.name
                  session['client_family'] = user.family
                  session['client_image'] = user.image
                  session['client_phone'] = user.tele
                  if 'next' in session:
                      next = session.get('next')
                      session.pop('next')
                      return redirect(next)
                  else:
                      flash('Привет, {}'.format(user.name), 'success')
                      return redirect(url_for('client.profile'))
              else:
                  flash('Неверные учетные данные.', 'danger')
                  return redirect(url_for('client.index'))
          else:
              flash('Неверные учетные данные.', 'danger')
              return redirect(url_for('client.index'))
      return render_template('index.html', form_login=form_login)
  </code></pre>
  
  <p><code>Abonent main route</code>:</p>
  
  <pre><code>@abonent_route.route('/', methods=['GET', 'POST'])
  def index():
      register_form = RegistrationForm()
      if request.method == 'POST':
          if register_form.is_submitted():
              if not register_form.terms_agree.data:
                  flash('Вы должны согласиться с нашим договором и со всеми его пунктами.', 'danger')
                  return redirect(url_for("abonent.index"))
              if register_form.master_salon.data or register_form.master_cto.data or register_form.master_company.data == True:
                  user = User()
                  user.name = register_form.name.data
                  user.family = register_form.family.data
                  user.bio = register_form.biography.data
                  if User.query.filter_by(tele=register_form.telephone.data).first():
                      flash('Этот номер: {} уже использован.'.format(register_form.telephone.data), "warning")
                      return redirect(url_for('abonent.index'))
                  else:
                      user.tele = register_form.telephone.data
                  user.set_password(register_form.password.data)
                  db.session.add(user)
                  db.session.commit()
      return redirect(url_for('abonent.confirm', phone=phone))
  return render_template('index.html', register_form=register_form)
  </code></pre>
  
  <p>Here is a link to where full error shows, this one is raises if the <strong>client route</strong> is under <strong>abonent route</strong> in <code>__init__.py</code> file:</p>
  
  <p><a href="https://pastebin.com/EQ77zstu" rel="nofollow noreferrer">Click to open</a></p>
  
  <p>Another thing that i forgot to mention is, if tried to open for example <code>/client/registration</code>, it opens without any error, the error raises if i wanted to access <code>/client</code> which is the index page for <code>client</code></p>