librelist archives

« back to archive

Using variable-routed URL for linking in template

Using variable-routed URL for linking in template

From:
Samrat Man Singh
Date:
2011-07-19 @ 16:26
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

Re: [flask] Using variable-routed URL for linking in template

From:
Julen Ruiz Aizpuru
Date:
2011-07-19 @ 16:41
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

Re: [flask] Using variable-routed URL for linking in template

From:
Josh Finnie
Date:
2011-07-19 @ 16:58
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

Re: [flask] Using variable-routed URL for linking in template

From:
Samrat Man Singh
Date:
2011-07-19 @ 17:19
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
>

Re: [flask] Using variable-routed URL for linking in template

From:
Samrat Man Singh
Date:
2011-07-19 @ 17:27
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
>>
>
>