index: django/views/generic/simple.py
|
|
|
| 1 | import urllib2 |
| 2 | |
1 | 3 | from django.template import loader, RequestContext |
2 | 4 | from django.http import HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponseGone |
3 | 5 | from django.utils.log import getLogger |
… |
… |
|
27 | 29 | t = loader.get_template(template) |
28 | 30 | return HttpResponse(t.render(c), mimetype=mimetype) |
29 | 31 | |
30 | | def redirect_to(request, url, permanent=True, query_string=False, **kwargs): |
| 32 | def redirect_to(request, url, permanent=True, query_string=False, url_encode=False, **kwargs): |
31 | 33 | """ |
32 | 34 | Redirect to a given URL. |
33 | 35 | |
… |
… |
|
47 | 49 | If the ``query_string`` argument is True, then the GET query string |
48 | 50 | from the request is appended to the URL. |
49 | 51 | |
| 52 | If the ``url_encode`` argument is True, the url is unquoted. |
| 53 | |
50 | 54 | """ |
51 | 55 | args = request.META["QUERY_STRING"] |
52 | 56 | if args and query_string and url is not None: |
53 | 57 | url = "%s?%s" % (url, args) |
54 | 58 | |
| 59 | if url_encode: |
| 60 | url = urllib2.unquote(url) |
| 61 | |
55 | 62 | if url is not None: |
56 | 63 | klass = permanent and HttpResponsePermanentRedirect or HttpResponseRedirect |
57 | 64 | return klass(url % kwargs) |