每当我运行此代码段时。我一直没有显示我的Checkbox,而是收到一条错误消息
UnboundField(BooleanField, (), {'label': 'hello'})
应显示复选框的位置。
表单类
class FilterForm(FlaskForm):
_attrs = ('name', 'desc')
header = "Enter Your Specific Filters"
name = StringField(label='Name')
desc = TextAreaField(label='Description')
索引类
from forms import FilterForm
@app.route('/config', methods=('GET', 'POST'))
@login_required
def config(product=None) -> str:
filterModal = FilterForm()
setattr(filterModal, "hello", BooleanField(label="hello"))
return render_template(
'master.html',
filterModal=filterModal)
HTML
{{ filterModal.hello }}