通过python flask中的select标记传递所选选项值
我有一个用户注册表格,上面有一个select标签。我希望将所选选项中的值指定给变量(代码如下所示) registration.html通过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 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")