Advertisement
maladmin

Untitled

Apr 5th, 2017
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.45 KB | None | 0 0
  1. class myForm(FlaskForm):
  2.     def __init__(self, *args, **kwargs):
  3.         super(myForm, self).__init__(*args, **kwargs)
  4.  
  5. @app.route('/search')
  6. def search():
  7.     class F(myForm):
  8.         pass
  9.  
  10.     fields = {'mytext': wtforms.TextField('myText'),
  11.               'myselect': wtForms.SelectField('mySelect', choices = [(1, 'a'), (2, 'b')])
  12.               }
  13.  
  14.     for key, val in fields.iteritems():
  15.         setattr(F, key, val)
  16.  
  17.     form = F()
  18.  
  19.     return render_template('search.html',
  20.                             form=form)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement