librelist archives

« back to archive

werkzeug.routing.BuildError

werkzeug.routing.BuildError

From:
Alasdair Macmillan
Date:
2010-08-19 @ 14:05
Hi

Quick question: I want to redirect to a url with an anchor.

return redirect(url_for('/#login'))

I am getting an error:

werkzeug.routing.BuildError
 BuildError: ('/#login', {}, None)

What's the problem? Does the # need escaped? 


Kind thanks
AL

Re: [flask] werkzeug.routing.BuildError

From:
Simon Sapin
Date:
2010-08-19 @ 14:12
Le 19/08/2010 16:05, Alasdair Macmillan a écrit :
> Hi
>
> Quick question: I want to redirect to a url with an anchor.
>
> return redirect(url_for('/#login'))

Hi,

You simply want this :
     return redirect('/#login')

url_for is to reconstruct URLs from view names. It could be used like this:
     return redirect(url_for('index') + '#login')

assuming:
     @app.route('/')
     def index():
         # ...

Sincerely,
-- 
Simon Sapin

Re: [flask] werkzeug.routing.BuildError

From:
Alasdair Macmillan
Date:
2010-08-19 @ 14:40
Thanks!

Another question is how do I post a form from a login form on every page. 
I have a form working from a page /login but when I use the same form on a
hidden div that's on every page (an expanding div that opens via jquery on
click) that I post to /login  it doesn't work. It seems to pass the fields
in the url

/login%20method=?username=al%40atomised.coop&password=testpassword

How can I make the view I have set up for the /login page available from 
any form posting from any page?


On 19 Aug 2010, at 15:12, Simon Sapin wrote:

> return redirect('/#login')