[Flask] "could not build URL for endpoint"?

Alex Hall ahall at autodist.com
Wed May 11 09:22:01 EDT 2016


Hello list,
I have no idea what I changed--I've been messing with so many config files
and apps lately--but suddenly I'm getting that error when I load my app. My
templates use the 'url_for' function, as I'm told they should, but that
seems to be failing for some reason. The only related change I can think of
is that I recently added a couple more decorators to a view function, in an
effort to always direct to a certain view when visitors go to the main
site. That is
myapp.mysite.com/search
is redirected to by
myapp.mysite.com
or
myapp.mysite.com/index

The error is "could not build URL for endpoint '/index'. Did you mean
'/search' instead?

In my base template, I define a navigation bar. In the exception, the first
url in that bar is causing the problem:
a href="{{url_for("/index")}}">Home</a

Might the problem be that I'm defining a link (/index) that will render as
this view, because that's a decorator before the /search function? That
doesn't make much sense to me, but I can't think what else it could be.
Related: is there a better way of directing to a certain view than putting
a bunch of app.route decorators in front of a single function? Is the
recommended way to handle this in the web server configuration instead?


-- 
Alex Hall
Automatic Distributors, IT department
ahall at autodist.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20160511/490b9783/attachment.html>


More information about the Flask mailing list