ValueError: View Function Did Not Return a Response

Armin Ronacher

The Problem

Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/flask/", line 1836, in __call__ return self.wsgi_app(environ, start_response) File "/usr/local/lib/python2.7/dist-packages/flask/", line 1820, in wsgi_app response = self.make_response(self.handle_exception(e)) File "/usr/local/lib/python2.7/dist-packages/flask/", line 1403, in handle_exception reraise(exc_type, exc_value, tb) File "/usr/local/lib/python2.7/dist-packages/flask/", line 1817, in wsgi_app response = self.full_dispatch_request() File "/usr/local/lib/python2.7/dist-packages/flask/", line 1478, in full_dispatch_request response = self.make_response(rv) File "/usr/local/lib/python2.7/dist-packages/flask/", line 1566, in make_response raise ValueError('View function did not return a response') ValueError: View function did not return a response

The Solution

All Flask views must return a value, usually a Response object. If the flask view throwing the error accepts GET and POST methods, check if you are neglecting return a value for one of the cases.

@app.route('/', methods=['GET', 'POST']) def index(): if request.method == 'POST': # Failure to return a redirect or render_template else: return render_template('index.html')

Further Reading

If you’re looking to get a deeper understanding of how Flask application monitoring works, take a look at the following articles:

Join the discussionCome work with us
Share on Twitter
Bookmark this page
Ask a questionImprove this Answer

Related Answers

A better experience for your users. An easier life for your developers.

© 2023 • Sentry is a registered Trademark
of Functional Software, Inc.