Ticket #6892: simple.diff

File simple.diff, 1.3 KB (added by furryRevenge, 14 years ago)
  • django/views/generic/simple.py

    index: django/views/generic/simple.py
     
     1import urllib2
     2
    13from django.template import loader, RequestContext
    24from django.http import HttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponseGone
    35from django.utils.log import getLogger
     
    2729    t = loader.get_template(template)
    2830    return HttpResponse(t.render(c), mimetype=mimetype)
    2931
    30 def redirect_to(request, url, permanent=True, query_string=False, **kwargs):
     32def redirect_to(request, url, permanent=True, query_string=False, url_encode=False, **kwargs):
    3133    """
    3234    Redirect to a given URL.
    3335
     
    4749    If the ``query_string`` argument is True, then the GET query string
    4850    from the request is appended to the URL.
    4951
     52    If the ``url_encode`` argument is True, the url is unquoted.
     53
    5054    """
    5155    args = request.META["QUERY_STRING"]
    5256    if args and query_string and url is not None:
    5357        url = "%s?%s" % (url, args)
    5458
     59    if url_encode:
     60        url = urllib2.unquote(url)
     61
    5562    if url is not None:
    5663        klass = permanent and HttpResponsePermanentRedirect or HttpResponseRedirect
    5764        return klass(url % kwargs)
Back to Top