While building a flask application a got a problem with using {{ url_for() }} in my template.
I have this in my app.py:
@app.route("/revisal")
def revisal():
return render_template("questions.html")
And this in one of my templates:
<a href="{{ url_for('revisal') }}">...</a>
Everything works as intended on my local machine but I get a server error when I upload it to pythonanywhere. Here is error log:
2015-11-10 16:38:07,126 :Exception on /results [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.4/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/ignat/studyct/app.py", line 51, in process_form
result = score)
File "/usr/local/lib/python3.4/dist-packages/flask/templating.py", line 128, in render_template
context, ctx.app)
File "/usr/local/lib/python3.4/dist-packages/flask/templating.py", line 110, in _render
rv = template.render(context)
File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/lib/python3.4/dist-packages/jinja2/environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.4/dist-packages/jinja2/_compat.py", line 36, in reraise
raise value.with_traceback(tb)
File "/home/ignat/studyct/templates/results.html", line 1, in <module>
{% extends "base.html" %}
File "/home/ignat/studyct/templates/base.html", line 17, in <module>
{% block content %}
File "/home/ignat/studyct/templates/results.html", line 27, in <module>
<a href="{{ url_for('revisal') }}"><h2>Работа над ошибками</h2></a>
File "/usr/local/lib/python3.4/dist-packages/flask/helpers.py", line 312, in url_for
return appctx.app.handle_url_build_error(error, endpoint, values)
File "/usr/local/lib/python3.4/dist-packages/flask/app.py", line 1641, in handle_url_build_error
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.4/dist-packages/flask/_compat.py", line 33, in reraise
raise value
File "/usr/local/lib/python3.4/dist-packages/flask/helpers.py", line 305, in url_for
force_external=external)
File "/usr/local/lib/python3.4/dist-packages/werkzeug/routing.py", line 1616, in build
raise BuildError(endpoint, values, method)
werkzeug.routing.BuildError: ('revisal', {}, None)
Pls help.