我正在制作本教程。flask tutorial
但是,当我使用网络表单时,我收到了上述错误。
以下是Flask生成的错误消息。
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\workspace\Learn-flask\app\views.py", line 17, in login
return render_template('login.html', title='Sign In',form=form)
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\templating.py", line 128, in render_template
context, ctx.app)
File "C:\Python27\lib\site-packages\flask-0.10-py2.7.egg\flask\templating.py", line 110, in _render
rv = template.render(context)
File "C:\Python27\lib\site-packages\jinja2-2.7.1-py2.7.egg\jinja2\environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "C:\Python27\lib\site-packages\jinja2-2.7.1-py2.7.egg\jinja2\environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\workspace\Learn-flask\app\templates\login.html", line 1, in top-level template code
{% extends "base.html"%}
File "C:\workspace\Learn-flask\app\templates\base.html", line 17, in top-level template code
{% block content %}{% endblock %}
File "C:\workspace\Learn-flask\app\templates\login.html", line 9, in block "content"
<p>Open id :{{form.openid(80)}}<br/>
这是表单类代码
from flask_wtf import Form
from wtforms import StringField, BooleanField
from wtforms.validators import DataRequired
class LoginForm(Form):
openid = StringField('openid', validators=[DataRequired()])
remember_me = BooleanField('remember_me', default=False)
我在哪里做错了?
答案 0 :(得分:0)
wtforms.fields.Field.__call__
仅接受关键字参数,因为linked documentation状态。如果您想将80
作为maxlen
传递,请使用关键字参数:
{{ form.openid(maxlength=80) }}