Hi,
I need to place links on my template that point to URLs that are generated
through variables <http://flask.pocoo.org/docs/quickstart/#variable-rules>,
maybe something like <a href='{{ url_for('post/post_id') }}'> (this doesn't
work, but I hope you get the idea). How do I do this?
Samrat
ar., 2011.eko uztren 19a 18:26(e)an, Samrat Man Singh(e)k idatzi zuen: > Hi, > I need to place links on my template that point to URLs that are > generated through variables > <http://flask.pocoo.org/docs/quickstart/#variable-rules>, maybe > something like <a href='{{ url_for('post/post_id') }}'> (this doesn't > work, but I hope you get the idea). How do I do this? > The docs are excellent, you should look there before asking: http://flask.pocoo.org/docs/quickstart/#url-building
Looks like you should try:
<a href="{{ url_for('post', id=post_id) }}"
And:
@app.route('/post/<int:id>')
Haven't had time to test this unfortunately...
On Jul 19, 2011 12:42 PM, "Julen Ruiz Aizpuru" <julenx@gmail.com> wrote:
> ar., 2011.eko uztren 19a 18:26(e)an, Samrat Man Singh(e)k idatzi zuen:
>> Hi,
>> I need to place links on my template that point to URLs that are
>> generated through variables
>> <http://flask.pocoo.org/docs/quickstart/#variable-rules>, maybe
>> something like <a href='{{ url_for('post/post_id') }}'> (this doesn't
>> work, but I hope you get the idea). How do I do this?
>>
>
>
> The docs are excellent, you should look there before asking:
> http://flask.pocoo.org/docs/quickstart/#url-building
Josh, I've tried it it gives me a BuildError-
BuildError: ('post', {'id': 2}, None)
Julen,
I've already taken a look at the docs; I didn't really find something
specific to this problem though.
Samrat.
On Tue, Jul 19, 2011 at 10:43 PM, Josh Finnie <joshua.finnie@gmail.com>wrote:
> Looks like you should try:
>
> <a href="{{ url_for('post', id=post_id) }}"
>
> And:
>
> @app.route('/post/<int:id>')
>
> Haven't had time to test this unfortunately...
> On Jul 19, 2011 12:42 PM, "Julen Ruiz Aizpuru" <julenx@gmail.com> wrote:
> > ar., 2011.eko uztren 19a 18:26(e)an, Samrat Man Singh(e)k idatzi zuen:
> >> Hi,
> >> I need to place links on my template that point to URLs that are
> >> generated through variables
> >> <http://flask.pocoo.org/docs/quickstart/#variable-rules>, maybe
> >> something like <a href='{{ url_for('post/post_id') }}'> (this doesn't
> >> work, but I hope you get the idea). How do I do this?
> >>
> >
> >
> > The docs are excellent, you should look there before asking:
> > http://flask.pocoo.org/docs/quickstart/#url-building
>
I'm sorry, looks like I'd made a silly mistake. Problem got sorted at the IRC channel. Anyway, thanks!! On Tue, Jul 19, 2011 at 11:04 PM, Samrat Man Singh <samratmansingh@gmail.com > wrote: > Josh, I've tried it it gives me a BuildError- > > BuildError: ('post', {'id': 2}, None) > > Julen, > I've already taken a look at the docs; I didn't really find something > specific to this problem though. > > Samrat. > > On Tue, Jul 19, 2011 at 10:43 PM, Josh Finnie <joshua.finnie@gmail.com>wrote: > >> Looks like you should try: >> >> <a href="{{ url_for('post', id=post_id) }}" >> >> And: >> >> @app.route('/post/<int:id>') >> >> Haven't had time to test this unfortunately... >> On Jul 19, 2011 12:42 PM, "Julen Ruiz Aizpuru" <julenx@gmail.com> wrote: >> > ar., 2011.eko uztren 19a 18:26(e)an, Samrat Man Singh(e)k idatzi zuen: >> >> Hi, >> >> I need to place links on my template that point to URLs that are >> >> generated through variables >> >> <http://flask.pocoo.org/docs/quickstart/#variable-rules>, maybe >> >> something like <a href='{{ url_for('post/post_id') }}'> (this doesn't >> >> work, but I hope you get the idea). How do I do this? >> >> >> > >> > >> > The docs are excellent, you should look there before asking: >> > http://flask.pocoo.org/docs/quickstart/#url-building >> > >