0
我想为烧瓶wtforms中的字符串字段设置默认值。以下是我的代码,它不起作用。烧瓶窗体字段的动态默认值设置
代码:
from flask.ext.wtf import Form
from wtforms import StringField
class TestForm(Form):
test = StringField('Test field')
@app.route('display/')
def display():
dynamicvalue = getdynamicvalue()
return render_template('test.html', form = form, defname = dynamicvalue)
的test.html:
<div class="controls">
{{ form.test(size=80, readonly="readonly", value={{defname}} }}
</div>
如何纠正呢?
以下是错误
{{form.test(size=80, readonly= "readonly", value={{defname}} }}
TemplateSyntaxError: expected token ':', got '}'
我没有看到你的设置默认值? – 2015-11-05 13:26:24
这是我在stackoverflow中的错字。我用错误消息更新了我的代码 – pogo