<div dir="ltr">Forgot to give you these links on url_for:<div><br></div><div><a href="http://flask.pocoo.org/docs/0.10/api/#flask.url_for">http://flask.pocoo.org/docs/0.10/api/#flask.url_for</a><br></div><div><br></div><div><a href="http://flask.pocoo.org/docs/0.10/blueprints/#building-urls">http://flask.pocoo.org/docs/0.10/blueprints/#building-urls</a><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr">Anthony Ford,<br>KF5IBN,<div><a href="mailto:ford.anthonyj@gmail.com" target="_blank">ford.anthonyj@gmail.com</a></div></div></div></div>
<br><div class="gmail_quote">On Wed, May 11, 2016 at 8:32 AM, Anthony Ford <span dir="ltr"><<a href="mailto:ford.anthonyj@gmail.com" target="_blank">ford.anthonyj@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Your running into an uissue in that url_for doesn't take the path ( the "/foo/bar" in "<a href="http://example.com/foo/bar" target="_blank">example.com/foo/bar</a>") but the function which provides the view you want.<div><br></div><div>If you define a route (say "/index"), and the function that handles that route is foobar(), then you would use url_for('foobar').</div><div><br></div><div>So for:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span style="font-family:monospace,monospace">@app.route('/index')</span></div><div><span style="font-family:monospace,monospace">def foobar():</span></div><div><span style="font-family:monospace,monospace">    return render_template('foobar.html')</span></div></blockquote><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">your template would have the following link:</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><font face="monospace, monospace">a href="{{url_for('.foobar')}}">Home</a</font></div></blockquote><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Hope that helps!</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">Also, be careful with your quotes. While Jinja should pick up the quotes within {{}} and handle them well, even with the outer quotes, it's good to be in the habit of not mixing quotes. Use one type (i.e. double) for your outer, and the other (single) for your inner. Since Python doesn't differentiate between the types, it's safe to swap them as you desire. </font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><font face="monospace, monospace"><br></font></blockquote></div></div><div class="gmail_extra"><br clear="all"><div><div><div dir="ltr">Anthony Ford,<br>KF5IBN,<div><a href="mailto:ford.anthonyj@gmail.com" target="_blank">ford.anthonyj@gmail.com</a></div></div></div></div>
<br><div class="gmail_quote"><div><div class="h5">On Wed, May 11, 2016 at 8:22 AM, Alex Hall <span dir="ltr"><<a href="mailto:ahall@autodist.com" target="_blank">ahall@autodist.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr"><div><div><div><div><div><div><div><div><div>Hello list,<br></div>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<br></div><a href="http://myapp.mysite.com/search" target="_blank">myapp.mysite.com/search</a><br></div>is redirected to by<br></div><a href="http://myapp.mysite.com" target="_blank">myapp.mysite.com</a><br></div>or<br></div><a href="http://myapp.mysite.com/index" target="_blank">myapp.mysite.com/index</a><br><br></div><div>The error is "could not build URL for endpoint '/index'. Did you mean '/search' instead?<br></div><div><br></div>In my base template, I define a navigation bar. In the exception, the first url in that bar is causing the problem:<br></div>a href="{{url_for("/index")}}">Home</a<br><br></div>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?<span><font color="#888888"><br><div><br clear="all"><div><div><div><div><div><div><div><div><div><br>-- <br><div><div dir="ltr"><div><div>Alex Hall<br></div>Automatic Distributors, IT department<br></div><a href="mailto:ahall@autodist.com" target="_blank">ahall@autodist.com</a><br></div></div>
</div></div></div></div></div></div></div></div></div></div></font></span></div>
<br></div></div>_______________________________________________<br>
Flask mailing list<br>
<a href="mailto:Flask@python.org" target="_blank">Flask@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/flask" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/flask</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div>