title: SelectField WTforms not valid choice and sa_instance_state
body: <p>I'm encountering a number of errors when implementing a WTForms SelectField in an application built with Flask/SQLalchemy. </p>
  
  <p>Here's the relevant code:</p>
  
  <p><strong>Views.py:</strong></p>
  
  <pre><code>form = ReviewForm()
      if form.validate_on_submit():
          review = Review(rating=form.rating.data, body=form.body.data, pub_date=datetime.utcnow(), author=g.user, item=thing)
          db.session.add(review)
          db.session.commit()
  </code></pre>
  
  <p><strong>Models.py</strong></p>
  
  <pre><code>RATING_CHOICES = (
          (1, '1'),
          (2, 2),
          (3, 3),
          (4, 4),
          (5, 5),
      )
  
      id = db.Column(db.Integer, primary_key=True, autoincrement=True)
      pub_date = db.Column(db.DateTime)
      body = db.Column(db.Text)
      rating = db.Column(db.Integer)
  </code></pre>
  
  <p><strong>Forms.py</strong></p>
  
  <pre><code>class ReviewForm(Form):
      rating = SelectField('rating', choices=Review.RATING_CHOICES, validators=[Required()])
      body = TextAreaField('body', validators=[Required()])
      tags = StringField('tags', validators=[Required()])
  </code></pre>
  
  <p>So right now, with code as it is...I'm getting a "Not a valid choice" issue.  I'm assuming it's interpreting my rating as a string or tuple or something and as a result, it isn't feeding properly to <code>rating=db.column(db.Integer)</code>. </p>
  
  <p>However, upon adding coerce=int to the selectfield arguments, I start encountering: </p>
  
  <pre><code>AttributeError: 'AnonymousUserMixin' object has no attribute '_sa_instance_state'
  
  File "", line 194, in blank
  review = Review(rating=form.rating.data, body=form.body.data, pub_date=datetime.utcnow(), author=g.user, item=thing)
  File "&lt;string&gt;", line 4, in __init__
  </code></pre>
  
  <p>I'm clearly missing something here or sending something wrong...I'm just not savvy enough to dig into what the form is returning and figure it out.</p>