WTForms 错误:TypeError:formdata 应该是多字典类型包装器

发布于 2024-09-04 11:50:35 字数 1204 浏览 6 评论 0原文

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

当我在 webapp(gae) 上使用 LoginForm 时,如下所示:

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

如何使其运行

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不语却知心 2024-09-11 11:50:35

您应该传入 self.request.form (实际的表单字段,而不是整个请求)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文