diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-02-13 04:24:58 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-02-13 04:24:58 +0000 |
| commit | 0fabbf8ce849dd744d085bae073add038d574e2f (patch) | |
| tree | b120649a485282178910f3a29bfcaacb94f231b4 /docs | |
| parent | 58ae80b5ea66c0723571e233bd22d02403ba7fa7 (diff) | |
Fixed #2606 -- Added tag for working out the URL of a particular view function.
All work done by Ivan Sagalaev.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4494 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/templates.txt | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/docs/templates.txt b/docs/templates.txt index 651866e52e..51c3404513 100644 --- a/docs/templates.txt +++ b/docs/templates.txt @@ -829,6 +829,40 @@ The argument tells which template bit to output: Note: ``opencomment`` and ``closecomment`` are new in the Django development version. +url +~~~ + +Returns an absolute URL matching a given view function. 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 function. 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 use as positional and keyword arguments in the URL. All arguments +needed by the URL resolver should be present. + +For example, suppose 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') + +If this app's urlconf is included into the project's urlconf under a path +such as + +:: + + ('^clients/', include('project_name.app_name.urls')) + +then, in a template, you can create a link to this view like this:: + + {% url app_name.client client.id %} + +The URL rendered in the template will then look like ``/clients/client/123/``. + widthratio ~~~~~~~~~~ |
