【发布时间】:2013-03-15 10:02:32
【问题描述】:
我目前正在使用以下代码来生成标签:
{{ form.code.label(class="control-label required") }}
注意所需的类。 这现在是硬编码的,但我想根据 WTForms 字段信息动态添加:
form.code.flags.required
我尝试了类似的东西
{{ form.code.label(class="control-label {% if form.code.flags.required
%}required{% endif %}") }}
但它没有奏效。 有没有办法解决这个问题?
【问题讨论】:
标签: python google-app-engine python-2.7 jinja2 wtforms