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
This commit is contained in:
parent
231a7e0419
commit
e389234201
|
@ -49,8 +49,8 @@ Optional arguments
|
||||||
context_instance=RequestContext(request))
|
context_instance=RequestContext(request))
|
||||||
|
|
||||||
``mimetype``
|
``mimetype``
|
||||||
.. versionadded:: 1.0
|
.. versionadded:: 1.0
|
||||||
|
|
||||||
The MIME type to use for the resulting document. Defaults to the value of
|
The MIME type to use for the resulting document. Defaults to the value of
|
||||||
the :setting:`DEFAULT_CONTENT_TYPE` setting.
|
the :setting:`DEFAULT_CONTENT_TYPE` setting.
|
||||||
|
|
||||||
|
@ -84,21 +84,23 @@ This example is equivalent to::
|
||||||
|
|
||||||
.. function:: redirect(to[, permanent=False], *args, **kwargs)
|
.. function:: redirect(to[, permanent=False], *args, **kwargs)
|
||||||
|
|
||||||
|
.. versionadded:: 1.1
|
||||||
|
|
||||||
Returns an HttpResponseRedirect to the apropriate URL for the arguments
|
Returns an HttpResponseRedirect to the apropriate URL for the arguments
|
||||||
passed.
|
passed.
|
||||||
|
|
||||||
The arguments could be:
|
The arguments could be:
|
||||||
|
|
||||||
* A model: the model's `get_absolute_url()` function will be called.
|
* A model: the model's `get_absolute_url()` function will be called.
|
||||||
|
|
||||||
* A view name, possibly with arguments: `urlresolvers.reverse()` will
|
* A view name, possibly with arguments: `urlresolvers.reverse()` will
|
||||||
be used to reverse-resolve the name.
|
be used to reverse-resolve the name.
|
||||||
|
|
||||||
* A URL, which will be used as-is for the redirect location.
|
* A URL, which will be used as-is for the redirect location.
|
||||||
|
|
||||||
By default issues a temporary redirect; pass permanent=True to issue a
|
By default issues a temporary redirect; pass permanent=True to issue a
|
||||||
permanent redirect
|
permanent redirect
|
||||||
|
|
||||||
Examples
|
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
|
1. By passing some object; that object's
|
||||||
:meth:`~django.db.models.Model.get_absolute_url` method will be called
|
:meth:`~django.db.models.Model.get_absolute_url` method will be called
|
||||||
to figure out the redirect URL::
|
to figure out the redirect URL::
|
||||||
|
|
||||||
def my_view(request):
|
def my_view(request):
|
||||||
...
|
...
|
||||||
object = MyModel.objects.get(...)
|
object = MyModel.objects.get(...)
|
||||||
return redirect(object)
|
return redirect(object)
|
||||||
|
|
||||||
2. By passing the name of a view and optionally some positional or
|
2. By passing the name of a view and optionally some positional or
|
||||||
keyword arguments; the URL will be reverse resolved using the
|
keyword arguments; the URL will be reverse resolved using the
|
||||||
:func:`~django.core.urlresolvers.reverse` method::
|
:func:`~django.core.urlresolvers.reverse` method::
|
||||||
|
|
||||||
def my_view(request):
|
def my_view(request):
|
||||||
...
|
...
|
||||||
return redirect('some-view-name', foo='bar')
|
return redirect('some-view-name', foo='bar')
|
||||||
|
|
||||||
3. By passing a hardcoded URL to redirect to::
|
3. By passing a hardcoded URL to redirect to::
|
||||||
|
|
||||||
def my_view(request):
|
def my_view(request):
|
||||||
...
|
...
|
||||||
return redirect('/some/url/')
|
return redirect('/some/url/')
|
||||||
|
|
||||||
This also works with full URLs::
|
This also works with full URLs::
|
||||||
|
|
||||||
def my_view(request):
|
def my_view(request):
|
||||||
...
|
...
|
||||||
return redirect('http://example.com/')
|
return redirect('http://example.com/')
|
||||||
|
|
||||||
By default, :func:`redirect` returns a temporary redirect. All of the above
|
By default, :func:`redirect` returns a temporary redirect. All of the above
|
||||||
forms accept a ``permanent`` argument; if set to ``True`` a permanent redirect
|
forms accept a ``permanent`` argument; if set to ``True`` a permanent redirect
|
||||||
will be returned::
|
will be returned::
|
||||||
|
|
Loading…
Reference in New Issue