【发布时间】:2016-09-15 23:24:40
【问题描述】:
基本上,我在 Python 中有一个列表,并希望使用 WTForms 以编程方式调用并从该列表中创建一个下拉表单到 HTML 文档中。尝试在 WTForms 中使用 SelectField 方法时,我无法弄清楚我在这里缺少什么。该列表在“updatef”内。
我收到错误:ValueError:需要超过 1 个值才能解压 尝试运行时。
class ReusableForm(Form): # Define the form fields and validation parameters
updates = SelectField(u'Update Frequency', choices = updatef, validators = [validators.required()])
@app.route("/editor", methods=['GET', 'POST'])
def hello():
form = ReusableForm(request.form) # calls on form
if request.method == 'POST':
updates = request.form['updates']
HTML
<form id="main" action="" method="post" role="form" spellcheck="true">
<p> {{ form.updates }} </p>
【问题讨论】:
标签: python flask jinja2 wtforms flask-wtforms