Ticket #987: absolute.diff

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

     
    256256class HttpResponseRedirect(HttpResponse):
    257257    def __init__(self, redirect_to):
    258258        HttpResponse.__init__(self)
     259        # use absolute path if the site framework has been configured
     260        from django.contrib.sites.models import Site       
     261        mysite = Site.objects.all()[0]
     262        if mysite.domain != 'example.com' and not redirect_to.startswith('http://'):
     263            redirect_to = 'http://%s/%s' % (mysite.domain, redirect_to)
     264            redirect_to = os.path.normpath(redirect_to)
    259265        self['Location'] = quote(redirect_to, safe=RESERVED_CHARS)
    260266        self.status_code = 302
    261267
Back to Top