def wtform(): form = MyForm() if request.method == 'GET': return render_template('wtform_example.html', form=form) elif request.method == 'POST': if form.validate_on_submit(): flash("The form was successfully submitted", 'success') else: flash("There was a problem submitting the form!", 'danger') return render_template('wtform_example.html', form=form)
def wtform(): form = MyForm() if request.method == 'GET': return render_template('wtform_example.html', form=form) elif request.method == 'POST': if form.validate_on_submit(): mongo.db.operator.insert(form.data) flash(u'提交成功', 'success') else: flash(u'表单验证失败!', 'danger') return render_template('wtform_example.html', form=form)