summaryrefslogtreecommitdiff
path: root/docs/topics/http
diff options
context:
space:
mode:
authorJacob Kaplan-Moss <jacob@jacobian.org>2009-03-31 23:34:03 +0000
committerJacob Kaplan-Moss <jacob@jacobian.org>2009-03-31 23:34:03 +0000
commit516051bfd2b537f441c46359cce7eacbf15fc4b8 (patch)
treec518cb5727dcbbdeec08bf849e94bdfa7b5e36a7 /docs/topics/http
parent15becf23a9e4c9b230745738d2d42f6ab8f0f031 (diff)
A whole lotta documentation fixes: Fixes #8704, #8826, #8980, #9243, #9343, #9529,
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10303 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/topics/http')
-rw-r--r--docs/topics/http/shortcuts.txt2
-rw-r--r--docs/topics/http/urls.txt34
2 files changed, 35 insertions, 1 deletions
diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt
index 64633aae12..2bc35a3b9f 100644
--- a/docs/topics/http/shortcuts.txt
+++ b/docs/topics/http/shortcuts.txt
@@ -26,7 +26,7 @@ Required arguments
------------------
``template``
- The full name of a template to use.
+ The full name of a template to use or sequence of template names.
Optional arguments
------------------
diff --git a/docs/topics/http/urls.txt b/docs/topics/http/urls.txt
index 0d0f9ac889..4248d4f02e 100644
--- a/docs/topics/http/urls.txt
+++ b/docs/topics/http/urls.txt
@@ -633,6 +633,40 @@ reverse such patterns.
be imported correctly. Do not include lines that reference views you
haven't written yet, because those views will not be importable.
+resolve()
+---------
+
+The :func:`django.core.urlresolvers.resolve` function can be used for resolving
+URL paths to the corresponding view functions. It has the following signature:
+
+.. currentmodule:: django.core.urlresolvers
+.. function:: resolve(path, urlconf=None)
+
+``path`` is the URL path you want to resolve. As with ``reverse()`` above, you
+don't need to worry about the ``urlconf`` parameter. The function returns the
+triple (view function, arguments, keyword arguments).
+
+For example, it can be used for testing if a view would raise a ``Http404``
+error before redirecting to it::
+
+ from urlparse import urlparse
+ from django.core.urlresolvers import resolve
+ from django.http import HttpResponseRedirect, Http404
+
+ def myview(request):
+ next = request.META.get('HTTP_REFERER', None) or '/'
+ response = HttpResponseRedirect(next)
+
+ # modify the request and response as required, e.g. change locale
+ # and set corresponding locale cookie
+
+ view, args, kwargs = resolve(urlparse(next)[2])
+ kwargs['request'] = request
+ try:
+ view(*args, **kwargs)
+ except Http404:
+ return HttpResponseRedirect('/')
+ return response
permalink()
-----------