我使用来自http://flask.pocoo.org/snippets/60/的片段从我在 Flask 中的模型创建一个 WTForms 表单。一切正常,除了它只创建输入字段。我希望描述(见下面的models.py)是一个文本区域。有任何想法吗?
来自models.py:
title = db.Column(db.String(55))
description = db.Column(db.Text)
来自views.py
MyForm = model_form(MyModel, base_class=Form)
form = MyForm()
return render_template('create.html', form=form)
来自 create.html
{% for field in form %}
{{field.label}}
{{field}}
{% endfor %}
输出:
<input id="title" name="title" type="text" value="">
<input id="description" name="description" type="text" value="">
我想要的是:
<input id="title" name="title" type="text" value="">
<textarea id="description" name="description"></textarea>