“TypeError:'FormMeta'对象不可迭代”

时间:2014-08-21 11:09:18

标签: python flask jinja2 wtforms

这是我的WTForm

from flask.ext.wtf import Form
from wtforms import TextField, PasswordField, SelectMultipleField,HiddenField,validators
from wtforms.validators import Required, Email, EqualTo

class CreateCar(Form):
   id = HiddenField ('id')
   plaque_no = TextField('plaque_no', [Required(message='pn')])
   plaque_img = TextField('plaque_img', [Required(message='pi')])

这是我的Flask观点:

def manage(task=None,id=None):
    form = CreateCar
    return render('MyHTML.html', form=form)

每当我试图在我的表单字段上尝试:

{% for item in form %}
{{ item }}
{% endfor %}

我收到此错误:

TypeError: 'FormMeta' object is not iterable

我的表格有什么问题? 感谢

1 个答案:

答案 0 :(得分:5)

你只是想念CreateCar上的()。

def manage(task=None,id=None):
    form = CreateCar() #HERE
    return render('MyHTML.html', form=form)