summaryrefslogtreecommitdiff
path: root/django/views
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-01-03 23:57:14 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-01-03 23:57:14 +0000
commit3234a932b2054e30604d29f93e65180fa7c3fc05 (patch)
tree63a8123b914ba794b2fd219736863b0007c69f8a /django/views
parent6cca806943790a586a059bd2dacdf5d54e5f601d (diff)
Fixed #1117 -- Added HttpResponsePermanentRedirect
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1816 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/views')
-rw-r--r--django/views/generic/simple.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/django/views/generic/simple.py b/django/views/generic/simple.py
index 8a054e1ce7..086ed42805 100644
--- a/django/views/generic/simple.py
+++ b/django/views/generic/simple.py
@@ -1,28 +1,28 @@
from django.core.extensions import DjangoContext, render_to_response
-from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect, HttpResponseGone
+from django.utils.httpwrappers import HttpResponse, HttpResponsePermanentRedirect, HttpResponseGone
def direct_to_template(request, template, **kwargs):
"""
- Render a given template with any extra URL parameters in the context as
+ Render a given template with any extra URL parameters in the context as
``{{ params }}``.
"""
return render_to_response(template, {'params' : kwargs}, context_instance=DjangoContext(request))
-
+
def redirect_to(request, url, **kwargs):
"""
- Redirect to a given URL.
-
- The given url may contain dict-style string formatting which will be
+ Redirect to a given URL.
+
+ The given url may contain dict-style string formatting, which will be
interpolated against the params in the URL. For example, to redirect from
- ``/foo/<id>/`` to ``/bar/<id>/``, you could use the following urlpattern::
+ ``/foo/<id>/`` to ``/bar/<id>/``, you could use the following URLconf::
urlpatterns = patterns('',
('^foo/(?p<id>\d+)/$', 'django.views.generic.simple.redirect_to', {'url' : '/bar/%(id)s/'}),
)
-
+
If the given url is ``None``, a HttpResponseGone (410) will be issued.
"""
if url is not None:
- return HttpResponseRedirect(url % kwargs)
+ return HttpResponsePermanentRedirect(url % kwargs)
else:
- return HttpResponseGone() \ No newline at end of file
+ return HttpResponseGone()