代码: import wtforms from wtforms import validators from django.utils.datastructures import MultiValueDict
class Form(wtforms.Form): def __init__(self, handler=None, obj=None, prefix='', formdata=None, **kwargs): if handler: formdata = MultiValueDict() for name in handler.request.arguments.keys(): formdata.setlist(name, handler.get_argument(name))
class PostForm(Form): title = wtforms.TextField(u'Title', validators=[validators.Required()]) content = wtforms.TextAreaField(u'Content', validators=[validators.Required()])