你知道一种使HTML输入表单字段使用WTForms的'readonly'属性的方法吗?
此[示例][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)
Run Code Online (Sandbox Code Playgroud)
现在我想设置 QuerySelectField 的 selectlist 的默认值。
尝试default在 QuerySelectField 中传递 kwarg 并设置selected属性。什么都没起作用。我错过了一些明显的东西吗?有人可以帮忙吗?