title: Prepopulate Flask-WTForm IntegerField
body: <p>Simple form:</p>
  
  <pre><code>class AdjustPWMForm(Form):
      dutyCycle = IntegerField('dutycycle')
      #dutyCycle = IntegerField('dutycycle', default=44)
  </code></pre>
  
  <p>View function:</p>
  
  <pre><code> def adjust():
      user = g.user
      form = AdjustPWMForm()
      form.dutyCycle.data = 55
      if form.validate_on_submit():
          dutyCycle = form.dutyCycle.data
          print('result %s', dutyCycle)
          return redirect(url_for('statusPage'))
  
      return render_template('adjust.html', title='Adjust PWM', user=user, form=form)
  </code></pre>
  
  <p>When the form is submitted, the result is always 55, regardless of what has been entered.  If I comment out the 55 line, and uncomment the line with the default=44, the form works properly, but I really need to be able to set the prepopulate value (it will be retrieved from the database).</p>
  
  <p>It seems like I'm missing something really obvious, but I've hunted around and can't figure it out.</p>
  
  <p>I found the section in change_username useful in <a href="https://wtforms.readthedocs.org/en/latest/crash_course.html#getting-started" rel="nofollow">wtforms</a> which leads me to:</p>
  
  <pre><code>def adjust():
      user = g.user
      form = AdjustPWMForm(dutyCycle=55)
      if form.validate_on_submit():
          dutyCycle = form.dutyCycle.data
          return redirect(url_for('statusPage'))
  
      return render_template('adjust.html', title='Adjust PWM', user=user, form=form)
  </code></pre>
  
  <p>Is that the best way to accomplish this?</p>