【发布时间】:2014-03-02 00:13:30
【问题描述】:
这个[示例][1] 在 Flask 中使用 WTForms 和 SQLAlchemy 设置表单,并将 QuerySelectField 添加到表单中。我没有使用flask.ext.sqlalchemy,我的代码:
ContentForm = model_form(Content, base_class=Form)
ContentForm.author = QuerySelectField('Author', get_label="name")
myform = ContentForm(request.form, content)
myform.author.query = query_get_all(Authors)
现在我想设置 QuerySelectField 的选择列表的默认值。
尝试在 QuerySelectField 中传递 default kwarg 并设置 selected 属性。没有任何效果。我错过了什么明显的东西吗?有人可以帮忙吗?
【问题讨论】:
标签: python sqlalchemy flask selection wtforms