title: How do I prevent this form data from repopulating?
body: <p>I just finished making a simple number guessing webgame that tells the user whether their number is higher or lower than the solution.</p>
  
  <p>When submitting data to the webpage, the page updates properly with the game data, except that the text input field is filled in with data that was just previously submitted. It's annoying having to delete the text in the field before making another guess, I'd much prefer if it rendered the template with an empty form field.</p>
  
  <p>I was able to solve this issue in the past by using redirect instead of render_template, but I need render_template in this case to pass data to the page.</p>
  
  <p>Also, any general suggestions on my design would be appreciated, I'm quite new at this.</p>
  
  <p>Here is the page function:</p>
  
  <pre><code>@app.route('/numbers', methods=['GET', 'POST'])
  def numbers():
      x = open(os.path.join(basedir, 'textdata/nums.txt'), 'r')
      numdata = x.readlines()
      solved = True if numdata[0] == 'Solved\n' else False
      tries = int(numdata[1][:-1])
      answer = int(numdata[2])
      x.close()
      form = NumForm()
      newform = NewNumForm()
      if newform.validate_on_submit() and request.form['btn'] == 'New Game':
          randnum = randint(1, 100)
          x = open(os.path.join(basedir, 'textdata/nums.txt'), 'w')
          x.write('Unsolved\n0\n' + str(randnum))
          x.close()
          return redirect('/numbers')
      if form.validate_on_submit() and request.form['btn'] == 'Submit':
          num = form.num.data
          if num not in [str(i) for i in range(1, 101)]:
              return render_template('numbers.html', form=form, ttl='Numbers',
                                     tries = tries, wrongin = True)
          tries += 1
          if int(num) == answer:
              x = open(os.path.join(basedir, 'textdata/nums.txt'), 'w')
              x.write('Solved\n' + str(tries) + '\n' + str(answer))
              x.close()
              return render_template('numend.html', form=newform, ttl='Numbers',
                                     tries = tries, justsolved = True,
                                     answer = answer)
          if int(num) &gt; answer:
              greater = False
          if int(num) &lt; answer:
              greater = True
          x = open(os.path.join(basedir, 'textdata/nums.txt'), 'w')
          x.write('Unsolved\n' + str(tries) + '\n' + str(answer))
          x.close()
          return render_template('numbers.html', form=form, ttl='Numbers',
                                 tries = tries, greater = greater, num = num)
  
      if solved:
          return render_template('numend.html', form=newform, ttl='Numbers',
                                 tries = tries, answer = answer)
      return render_template('numbers.html', form=form, ttl='Numbers',
                             tries = tries)
  class NumForm(Form):
      num = StringField('num')
  
  class NewNumForm(Form):
      pass
  </code></pre>
  
  <p>And the page template:</p>
  
  <pre><code>{% extends "base.html" %}
  {% block content %}
      &lt;br&gt;
      &lt;br&gt;&lt;form action="" method="post" name="numform"&gt;
          {{ form.hidden_tag() }}
          &lt;p&gt;
              {% if num %}
              {% if greater %}
              The number is greater than {{ num }}
              {% else %}
              The number is smaller than {{ num }}
              {% endif %}
              {% endif %}
              &lt;h2&gt;Guess the number! (between 1 and 100)&lt;/h2&gt;
              &lt;br&gt;
              {{ form.num(size='3', autofocus=true) }}
              &lt;br&gt;
              {% for error in form.num.errors %}
                  &lt;span&gt;[{{ error }}]&lt;/span&gt;
              {% endfor %}&lt;br&gt;
          &lt;/p&gt;
          &lt;p&gt;&lt;input type="submit" value="Submit" name="btn"&gt;&lt;/p&gt;
          {% if wrongin %}
              &lt;span&gt;Whole numbers 1-100 only&lt;/span&gt;
              &lt;br&gt;
          {% endif %}
          Tries: {{ tries }}
      &lt;/form&gt;
      &lt;br&gt;
  {% endblock %}
  </code></pre>