title: Using WTForms' populate_obj( ) method with Flask micro framework
body: <p>I have a template which allows the user to edit their user information.</p>
  
  <pre><code>&lt;form method="post"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;Username:&lt;/td&gt;
              &lt;td&gt;{{user['username']}}&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;New Password:&lt;/td&gt;
              &lt;td&gt; &lt;input type="password" name="password"&gt;&lt;/td&gt;
              &lt;td&gt;{% if form.password.errors %} {{form.password.errors}} {% endif %}&lt;td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;Re-enter Password:&lt;/td&gt;
              &lt;td&gt; &lt;input type="password" name="confirm_password"&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;input type='hidden' name='username' value="{{user['username']}}"&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="submit" value="Submit"&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>I also have a view function for handling such edits by the user. The database I am currently using is <a href="http://en.wikipedia.org/wiki/MongoDB" rel="noreferrer">MongoDB</a> with the <a href="http://pypi.python.org/pypi/mongokit" rel="noreferrer">MongoKit</a> module. I have only been able to do up to this so far in the view function, yet with no luck.</p>
  
  <pre><code>def edit():
      username = request.args.get('user')
      user = User.find_one({'username':username}) # Is this a correct way of doing it?
      form = UserForm(**what should be placed here?**, obj=user)
  
      if request.method == 'POST' and form.validate():
          form.populate_obj(user)
          user.save()
          return 'updated'
      return render_template('edituser.html', form=form, user=user)
  </code></pre>
  
  <p>I am going through <a href="http://wtforms.simplecodes.com/docs/0.6.1/forms.html#wtforms.form.Form.populate_obj" rel="noreferrer">populate_obj(obj)</a> for this purpose. I couldn't find much help in this matter. What should I do in order to get <code>populate_obj()</code> working?</p>