基本上,我在Python中有一个列表,我想通过编程方式调用并使用WTForms在HTML文档中创建一个下拉表单。当尝试在WTForms中使用SelectField方法时,我不知道我在这里遗漏了什么。列表在“updatef”中。在
我得到错误:值错误:需要多于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格式
^{pr2}$
choices
必须是2个值元组的列表,例如[(1,'Daily'),(2,'Weekly')]
-您的错误似乎表明您可能只有一个值列表。在相关问题 更多 >
编程相关推荐