summaryrefslogtreecommitdiff
path: root/docs/url_dispatch.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-06-07 21:49:06 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-06-07 21:49:06 +0000
commitd34639b09bf85dfb1b6f9a4b59f8ccbc3117230b (patch)
tree619db1e6fde32bbfb0c135bde382d1b1df395e9a /docs/url_dispatch.txt
parent659d99b7afda730180e80ea4d68a7d505b21ba86 (diff)
newforms-admin: Merged to [5439]
git-svn-id: http://code.djangoproject.com/svn/django/branches/newforms-admin@5440 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/url_dispatch.txt')
-rw-r--r--docs/url_dispatch.txt35
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/url_dispatch.txt b/docs/url_dispatch.txt
index 39eed0625b..402b1200b5 100644
--- a/docs/url_dispatch.txt
+++ b/docs/url_dispatch.txt
@@ -551,3 +551,38 @@ not restricted to valid Python names.
Putting a prefix on your URL names, perhaps derived from the application
name, will decrease the chances of collision. We recommend something like
``myapp-comment`` instead of ``comment``.
+
+Utility methods
+===============
+
+reverse()
+---------
+
+If you need to use something similar to the ``{% url %}`` template tag in your
+code, Django provides the ``django.core.urlresolvers.reverse()``. The
+``reverse()`` function has the following signature::
+
+ reverse(viewname, urlconf=None, args=None, kwargs=None)
+
+``viewname`` is either the function name (either a function reference, or the
+string version of the name, if you used that form in ``urlpatterns``) or the
+`URL pattern name`_. Normally, you won't need to worry about the
+``urlconf`` parameter and will only pass in the positional and keyword
+arguments to use in the URL matching. For example::
+
+ from django.core.urlresolvers import reverse
+
+ def myview(request):
+ return HttpResponseRedirect(reverse('arch-summary', args=[1945]))
+
+.. _URL pattern name: `Naming URL patterns`_
+
+permalink()
+-----------
+
+The ``permalink()`` decorator is useful for writing short methods that return
+a full URL path. For example, a model's ``get_absolute_url()`` method. Refer
+to the `model API documentation`_ for more information about ``permalink()``.
+
+.. _model API documentation: ../model-api/#the-permalink-decorator
+