[英]TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given
I'm learning Flask and i can't make my form working. 我正在学习Flask,但无法使表格正常工作。 The form should get the name of user and print it on the same page 该表格应获取用户名并将其打印在同一页面上
Form: 形成:
class LoginForm(FlaskForm):
name = StringField(
'What is your name?',
validators=[Length(min = 4, max = 25), Required])
submit = SubmitField('Submit')
Views: 观看次数:
@app.route('/login/', methods=['GET','POST'])
def login():
name = None
formi = LoginForm()
if formi.validate_on_submit():
name = formi.name.data
formi.name.data = ''
return render_template('LoginForm.html', formi = formi, name = name)
Template: 模板:
<form action="" method="post" name="login">
{{ formi.hidden_tag() }}
<p>Enter your nickname</p>
{{ formi.name(size=25) }}
<input type="submit" value="Submit form">
</form>
Error: 错误:
TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given
Please check the if the spelling is right > " formi" 请检查拼写是否正确>“ formi”
@app.route('/login/', methods=['GET','POST'])
def login():
name = None
**formi** = LoginForm()
if formi.validate_on_submit():
name = formi.name.data
formi.name.data = ''
return render_template('LoginForm.html', formi = formi, name = name)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.