url

Returns an absolute URL matching given view with its parameters.

Documentation for using url tag

This is a way to define links that aren't tied to a particular URL
configuration:

{% url path.to.some_view arg1,arg2,name1=value1 %}

The first argument is a path to a view. It can be an absolute python path or
just app_name.view_name without the project name if the view is located
inside the project. Other arguments are comma-separated values that will be
filled in place of positional and keyword arguments in the URL. All
arguments for the URL should be present.

For example if you have a view app_name.client taking client's id and the
corresponding line in a URLconf looks like this:

('^client/(\d+)/$', 'app_name.client')

and this app's URLconf is included into the project's URLconf under some
path:

('^clients/', include('project_name.app_name.urls'))

then in a template you can create a link for a certain client like this:

{% url app_name.client client.id %}

The URL will look like /clients/client/123/.
Note: you can uncomment admin/doc part from urls.view to see the docs.

On Wed, Jun 10, 2009 at 12:02 PM, Margie <margierogin...@yahoo.com> wrote:

>
> I'm trying to figure out how to use the {% url %} tag in conjunction
> with a context variable.  For example, I have the context variable
> 'app_name' available in my template, and I'd like to do something like
> this:
>
> <a href="{% url list_{{app_name}} %}">List {{app_name}}</a>
>
> Anyone know how to do this?
>
> Margie
> >
>


-- 
Dhruv Adhia
http://thirdimension.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to