Ticket #987: absolute2.diff

File absolute2.diff, 1.0 KB (added by Simon G. <dev@…>, 8 years ago)
  • django/http/__init__.py

     
    33from pprint import pformat
    44from urllib import urlencode, quote
    55from django.utils.datastructures import MultiValueDict
     6from django.conf import settings
    67
    78RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
    89
     
    256257class HttpResponseRedirect(HttpResponse):
    257258    def __init__(self, redirect_to):
    258259        HttpResponse.__init__(self)
     260        # use absolute path if the site framework has been configured
     261        from django.contrib.sites.models import Site       
     262        mysite = Site.objects.get(pk=settings.SITE_ID)
     263        if mysite.domain != 'example.com' and not redirect_to.startswith('http://'):
     264            redirect_to = 'http://%s/%s' % (mysite.domain, redirect_to)
     265            redirect_to = os.path.normpath(redirect_to)
    259266        self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)
    260267        self.status_code = 302
    261268
Back to Top