diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2008-12-08 04:53:34 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2008-12-08 04:53:34 +0000 |
| commit | b76d7c1decb04cdb7ec363cd589f273952ab789a (patch) | |
| tree | 2fa7743da37cca1ae94cfaaa21f11d9e9c9ca935 /docs/ref/generic-views.txt | |
| parent | e9b90d98998da48d4ac18aabe135fa4200547be5 (diff) | |
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
Diffstat (limited to 'docs/ref/generic-views.txt')
| -rw-r--r-- | docs/ref/generic-views.txt | 17 |
1 files changed, 16 insertions, 1 deletions
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/<id>/`` to ``/bar/<id>/``:: +This example issues a permanent redirect (HTTP status code 301) from +``/foo/<id>/`` to ``/bar/<id>/``:: urlpatterns = patterns('django.views.generic.simple', ('^foo/(?P<id>\d+)/$', 'redirect_to', {'url': '/bar/%(id)s/'}), ) +This example issues a non-permanent redirect (HTTP status code 302) from +``/foo/<id>/`` to ``/bar/<id>/``:: + + urlpatterns = patterns('django.views.generic.simple', + ('^foo/(?P<id>\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', |
