WTForms error:TypeError: formdata should be a multidict-type wrapper

蹲街弑〆低调 提交于 2019-12-04 03:46:04

问题


from wtforms import Form, BooleanField, TextField, validators,PasswordField
class LoginForm(Form):
    username     = TextField('Username', [validators.Length(min=4, max=25)])
    password = PasswordField('Password')

when i use LoginForm on webapp(gae) like this :

def post(self):
    form=LoginForm(self.request)

but it show error :

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

how to make it running

thanks


回答1:


You are supposed to pass in self.request.form (the actual form fields, not the entire request)



来源:https://stackoverflow.com/questions/2978986/wtforms-errortypeerror-formdata-should-be-a-multidict-type-wrapper

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!