title: Setting a default value in the selectfield, using wtforms and flask
body: <p>I am creating a product edit form and I need the form to be pre-populated with the previous data. </p>
  
  <p>I am doing the following:</p>
  
  <pre><code>Product(form):
      product = TextField('name')
      category = SelectField('category', choice=[(1,'one'),(2,'two')])
  </code></pre>
  
  <p>In the view:</p>
  
  <pre><code>form.product.data = 'A product name from the database'
  form.category.data = 'a category name' #This does not work
  </code></pre>
  
  <p>The issue is with the SelectField. </p>
  
  <p>I understand there is a 'default' value I can set on SelectField. However, this happens in the form definition class and there I do not have the query object from sqlalchemy yet. </p>
  
  <p>So, is there a way to append a default on selectfield on run time? </p>