title: Flask - Pass Variables From Redirect to render_template
body: <p>I have a question regarding redirecting to a function that renders a template.  I have two functions:</p>
  
  <pre><code>@user.route('/register', methods=['GET', 'POST'])
  def register():
      if request.method == 'GET':
          return render_template('register.html')
      email = request.form['email']
      if User.query.filter(User.email == email).first() is not None:
          flash('Account already exists for this email address!')
          return redirect(url_for('user.login'))
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@user.route('/login', methods=['GET', 'POST'])
  def login():
      if request.method == 'GET':
          return render_template('login.html')
      return "Hello"
  </code></pre>
  
  <p>In the first function, with the line <code>return redirect(url_for('user.login'))</code>, I want to pass the email variable with that redirect, so I can have <code>render_template</code> in the second function display that variable on an HTML page.  I tried the following:</p>
  
  <pre><code>return redirect(url_for('user.login', defaultEmail=email))
  </code></pre>
  
  <p>in the first function and</p>
  
  <pre><code>return render_template('login.html', defaultEmail=email))
  </code></pre>
  
  <p>but it gives me <code>NameError: global name 'email' is not defined</code>.  How would I go about doing this?</p>