简体   繁体   English

TypeError:__init __()从1到2个位置参数,但给出了3个

[英]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.

相关问题 Money 和 TypeError:__init__() 需要 1 到 2 个位置参数,但给出了 3 个 - Money and TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given - TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given 继承 TypeError: __init__() 接受 1 到 2 个位置参数,但给出了 8 个 - inheritance TypeError: __init__() takes from 1 to 2 positional arguments but 8 were given Tkinter | TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given - Tkinter | TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given Python: TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given - Python : TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given python super:TypeError:__init __()接受2个位置参数,但给出了3个 - python super :TypeError: __init__() takes 2 positional arguments but 3 were given 类型错误:__init__() 需要 2 个位置参数,但给出了 4 个 - TypeError: __init__() takes 2 positional arguments but 4 were given 多个 inheritance,TypeError: __init__() 需要 2 个位置 arguments 但给出了 3 个 - multiple inheritance, TypeError: __init__() takes 2 positional arguments but 3 were given TypeError:__init __()接受2个位置参数,但是给了3个Python 3? - TypeError: __init__() takes 2 positional arguments but 3 were given Python 3? TypeError: __init__() 需要 3 个位置参数,但有 4 个给出了键盘命令 - TypeError: __init__() takes 3 positional arguments but 4 were given Keyboard Commands
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM