WTForms错误:TypeError:formdata应为multidict类型包装器
from wtforms import Form, BooleanField, TextField, validators,PasswordField
class LoginForm(Form):
username = TextField('Username', [validators.Length(min=4, max=25)])
password = PasswordField('Password')
当我在网络应用(gae)中这样使用登录表单时:
def post(self):
form=LoginForm(self.request)
但是它显示错误:
Traceback (most recent call last):
File "D:\Program Files\Google\google_appengine\google\appengine\ext\webapp\__init__.py", line 513, in __call__
handler.post(*groups)
File "D:\zjm_code\forum_blog_gae\main.py", line 189, in post
form=LoginForm(self.request)
File "D:\zjm_code\forum_blog_gae\wtforms\form.py", line 161, in __call__
return type.__call__(cls, *args, **kwargs)
File "D:\zjm_code\forum_blog_gae\wtforms\form.py", line 214, in __init__
self.process(formdata, obj, **kwargs)
File "D:\zjm_code\forum_blog_gae\wtforms\form.py", line 85, in process
raise TypeError("formdata should be a multidict-type wrapper that supports the 'getlist' method")
TypeError: formdata should be a multidict-type wrapper that supports the 'getlist' method
怎么才能让它正常运行呢
谢谢
1 个回答
7
你需要传入的是 self.request.form
,也就是实际的表单字段,而不是整个请求。