Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过python flask中的select标记传递所选选项值_Python_Html_Flask_Flask Wtforms - Fatal编程技术网

通过python flask中的select标记传递所选选项值

通过python flask中的select标记传递所选选项值,python,html,flask,flask-wtforms,Python,Html,Flask,Flask Wtforms,我有一个用户注册表格,上面有一个select标签。我希望将所选选项中的值指定给变量(代码如下所示) registration.html 但这似乎不起作用。非常感谢您的帮助。谢谢。您正在混合单选按钮和选择下拉列表 在模板中更改以下内容: <select id= "studenttype" name="studenttype"> <input type="radio" name="Theorist" val

我有一个用户注册表格,上面有一个select标签。我希望将所选选项中的值指定给变量(代码如下所示)

registration.html


但这似乎不起作用。非常感谢您的帮助。谢谢。

您正在混合单选按钮和选择下拉列表

在模板中更改以下内容:

                  <select id= "studenttype" name="studenttype">
                    <input type="radio" name="Theorist" value="Theorist"><span>Read lecture notes</span><br/>
                    <input type="radio" name="Theorist" value="Activist"><span>Watch videos</span>
                  </select>
@app.route('/register', methods=['GET', 'POST'])
def register():
    learning_style = request.form.get("studenttype")
    form = RegisterForm(request.form)
    if request.method == "POST" and form.validate():
        name = form.name.data
        email = form.email.data
        username = form.username.data
        password = form.password.data
        user_type = 'student'
        print(learning_style)

        ...........

        flash('You are now registered', 'success')
        redirect(url_for('index'))
    return render_template('register.html', form=form)
                  <select id= "studenttype" name="studenttype">
                    <input type="radio" name="Theorist" value="Theorist"><span>Read lecture notes</span><br/>
                    <input type="radio" name="Theorist" value="Activist"><span>Watch videos</span>
                  </select>
                    <input type="radio" name="Theorist" value="Theorist"><span>Read lecture notes</span><br/>
                    <input type="radio" name="Theorist" value="Activist"><span>Watch videos</span>
learning_style = request.form.get("Theorist")