From e389234201b3799b1037536ad1e9cb0496628721 Mon Sep 17 00:00:00 2001 From: Gary Wilson Jr Date: Sat, 21 Mar 2009 15:26:56 +0000 Subject: [PATCH] Added a versionadded directive to new redirect shortcut (refs #10194). git-svn-id: http://code.djangoproject.com/svn/django/trunk@10111 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/topics/http/shortcuts.txt | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/topics/http/shortcuts.txt b/docs/topics/http/shortcuts.txt index 11b17ed4a8..f2e45728d6 100644 --- a/docs/topics/http/shortcuts.txt +++ b/docs/topics/http/shortcuts.txt @@ -49,8 +49,8 @@ Optional arguments context_instance=RequestContext(request)) ``mimetype`` - .. versionadded:: 1.0 - + .. versionadded:: 1.0 + The MIME type to use for the resulting document. Defaults to the value of the :setting:`DEFAULT_CONTENT_TYPE` setting. @@ -84,21 +84,23 @@ This example is equivalent to:: .. function:: redirect(to[, permanent=False], *args, **kwargs) + .. versionadded:: 1.1 + Returns an HttpResponseRedirect to the apropriate URL for the arguments passed. - + The arguments could be: - + * A model: the model's `get_absolute_url()` function will be called. - + * A view name, possibly with arguments: `urlresolvers.reverse()` will be used to reverse-resolve the name. - + * A URL, which will be used as-is for the redirect location. - + By default issues a temporary redirect; pass permanent=True to issue a permanent redirect - + Examples -------- @@ -107,32 +109,32 @@ You can use the :func:`redirect` function in a number of ways. 1. By passing some object; that object's :meth:`~django.db.models.Model.get_absolute_url` method will be called to figure out the redirect URL:: - + def my_view(request): ... object = MyModel.objects.get(...) return redirect(object) - + 2. By passing the name of a view and optionally some positional or keyword arguments; the URL will be reverse resolved using the :func:`~django.core.urlresolvers.reverse` method:: - + def my_view(request): ... return redirect('some-view-name', foo='bar') - + 3. By passing a hardcoded URL to redirect to:: - + def my_view(request): ... return redirect('/some/url/') - + This also works with full URLs:: - + def my_view(request): ... return redirect('http://example.com/') - + By default, :func:`redirect` returns a temporary redirect. All of the above forms accept a ``permanent`` argument; if set to ``True`` a permanent redirect will be returned::