title: WTForms: I can't seem to dynamically give a QuerySelectField a default value
body: <p>I have a form which looks sort of like this:</p>
  
  <pre><code>class AddProductForm(Form):
      title = TextField('Title')
      type = QuerySelectField('Type',
          query_factory=lambda: ProductType.query.order_by(ProductType.sequence).all())
  
      def __init__(self, formdata=None, obj=None, prefix='', **kwargs):
          try:
              product_type_id = ProductType.query.filter_by(name=obj['product_type']).one().product_type_id
              kwargs.setdefault('type', product_type_id)
          except NoResultFound:
              pass
  
          Form.__init__(self, formdata, obj, prefix, **kwargs)
  </code></pre>
  
  <p>As you can see I am trying to set this up to give a sensible default for the product_type when the form is loaded. However, while this kind of code worked for setting a title as an example, it isn't working for the QuerySelectField 'type'. Does anybody have any ideas how I could fix this?</p>
  
  <p>Supposing that this isn't possible, does anybody know how I could dynamically add form elements to a form?</p>