title: How to pass data from a QuerySelectField in flask?
body: <p>In my application i have a QuerySelectField to populate a dropdown menu.
  I get the choices details for the queryselectfield from the db. Once user select any choice from dropdown menu and click on Submit button which is a POST method, i want to pass the value that user selected from the dropdown to a db to store. But it always return the value None from the queryselectfield. So db stores the data as None.</p>
  
  <p>models.py</p>
  
  <pre><code>class Orders(db.Model):
      __tablename__ = 'orders'
      id = db.Column(db.Integer, primary_key=True)
      name = db.Column(db.String(64))
      email = db.Column(db.String(120))
      resturant = db.Column(db.String(64))
      food = db.Column(db.String(64)))
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>def possible_res():
      return Resturant.query.all()
  
  def possible_menu():
      return Menu.query.all()
  
  class OrderForm(Form):
  
      sel_res = QuerySelectField(query_factory=possible_res,
                                 get_label='name')
  
      sel_menu = QuerySelectField(query_factory=possible_menu,
                                  get_label='food',
                                  allow_blank=False
                                  )
      submit = SubmitField("Confirm")
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>@app.route('/resturant', methods=['GET','POST'])
  def resturant():
      form = OrderForm()
      if request.method == 'GET':
          test = form.sel_menu.data
          return render_template("make_order.html", form=form, test=test)
      else:
          a = User.query.filter_by(email = session['email']).all()
          for u in a:
              name = u.firstname
  
          b = Orders(name=name, email=session['email'])
          b.resturant = form.sel_res.data
          b.food = form.sel_menu.data
          db.session.add(b)
          db.session.commit()
          return redirect('/')
  </code></pre>