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