使用form.validate_on_submit()
时出现错误,显示
`UnboundField'对象不可调用
@app.route('/register', methods=['GET', 'POST'])
def register():
form = RegistrationForm(request.form)
if form.validate_on_submit():
flash({form.username.data}, 'success')
return 'i did it'
forms.py
class RegistrationForm(FlaskForm):
username = StringField('Username',
validators=[DataRequired(), Length(min=2, max=15)])
email = StringField('Email ',
validators=[DataRequired(), Email()])
password = PasswordField('Password',
validators=[DataRequired()])
# confirm_password = PasswordField('confirm_password',
# validators=[DataRequired(), EqualTo('password')])
submit = SubmitField('SignUp', validators=[])