From b76d7c1decb04cdb7ec363cd589f273952ab789a Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 8 Dec 2008 04:53:34 +0000 Subject: Added a 'permanent' argument the simple.redirect_to() generic view. It's True by default, to match existing behavior. If set to False, the redirect will be a 302 instead of a 301. This is technically backwards-incompatible if you were using the redirect_to generic view with a format-string key called 'permanent', which is highly, highly unlikely. git-svn-id: http://code.djangoproject.com/svn/django/trunk@9594 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/ref/generic-views.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/ref/generic-views.txt b/docs/ref/generic-views.txt index c14cc295d2..efa49e3ee3 100644 --- a/docs/ref/generic-views.txt +++ b/docs/ref/generic-views.txt @@ -129,14 +129,29 @@ If the given URL is ``None``, Django will return an ``HttpResponseGone`` (410). * ``url``: The URL to redirect to, as a string. Or ``None`` to raise a 410 (Gone) HTTP error. +**Optional arguments:** + + * ``permanent``: Whether the redirect should be permanent. The only + difference here is the HTTP status code returned. If ``True``, then the + redirect will use status code 301. If ``False``, then the redirect will + use status code 302. By default, ``permanent`` is ``True``. + **Example:** -This example redirects from ``/foo//`` to ``/bar//``:: +This example issues a permanent redirect (HTTP status code 301) from +``/foo//`` to ``/bar//``:: urlpatterns = patterns('django.views.generic.simple', ('^foo/(?P\d+)/$', 'redirect_to', {'url': '/bar/%(id)s/'}), ) +This example issues a non-permanent redirect (HTTP status code 302) from +``/foo//`` to ``/bar//``:: + + urlpatterns = patterns('django.views.generic.simple', + ('^foo/(?P\d+)/$', 'redirect_to', {'url': '/bar/%(id)s/', 'permanent': False}), + ) + This example returns a 410 HTTP error for requests to ``/bar/``:: urlpatterns = patterns('django.views.generic.simple', -- cgit v1.3