本文介绍了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')

当我在webapp(gae)上使用LoginForm时,像这样:

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

如何让它运行

谢谢

thanks

推荐答案

$ c> self.request.form (实际的表单字段,而不是整个请求)

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

这篇关于WTForms错误:TypeError:formdata应该是一个multidict类型的包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:49