Ticket #6892: 6892v1.diff
File 6892v1.diff, 1.3 KB (added by , 17 years ago) |
---|
-
django/views/generic/simple.py
1 1 from django.shortcuts import render_to_response 2 2 from django.template import loader, RequestContext 3 3 from django.http import HttpResponse, HttpResponsePermanentRedirect, HttpResponseGone 4 from django.utils.encoding import iri_to_uri 4 5 5 6 def direct_to_template(request, template, extra_context=None, mimetype=None, **kwargs): 6 7 """ … … 22 23 """ 23 24 Redirect to a given URL. 24 25 25 The given url may contain dict-style string formatting, which will be26 interpolated against the params in the URL. For example, to redirect from26 The given url may contain unicode characters as well as dict-style string formatting, 27 which will be interpolated against the params in the URL. For example, to redirect from 27 28 ``/foo/<id>/`` to ``/bar/<id>/``, you could use the following URLconf:: 28 29 29 30 urlpatterns = patterns('', … … 33 34 If the given url is ``None``, a HttpResponseGone (410) will be issued. 34 35 """ 35 36 if url is not None: 36 return HttpResponsePermanentRedirect( url % kwargs)37 return HttpResponsePermanentRedirect(iri_to_uri(url % kwargs)) 37 38 else: 38 39 return HttpResponseGone()