#24967: FORCE_SCRIPT_NAME causes HttpResponseRedirect to fail
-------------------------+-------------------------------------------------
     Reporter:           |      Owner:  nobody
  seanherron             |
         Type:  Bug      |     Status:  new
    Component:  Core     |    Version:  1.8
  (URLs)                 |   Keywords:  SCRIPT_NAME,
     Severity:  Normal   |  FORCE_SCRIPT_NAME,redirect,HttpResponseRedirect
 Triage Stage:           |  Has patch:  0
  Unreviewed             |
Easy pickings:  0        |      UI/UX:  0
-------------------------+-------------------------------------------------
 When FORCE_SCRIPT_NAME is set in settings, redirects using
 HttpResponseRedirect seem to fail.

 '''Expected behavior:'''
 While FORCE_SCRIPT_NAME is enabled (set to `foo`), HttpResponseRedirect
 should return the user to a correct path, prepended with the script name.
 (eg, `/foo/bar`).

 '''Actual behavior:'''
 HttpResponseRedirect doubles the script name and redirects the user to
 `/foo/foo/bar`.


 As a workaround, I created a utility function to reconstruct a full URL to
 redirect the user to, but this should not be necessary.


 {{{
 from django.shortcuts import redirect
 from django.core.urlresolvers import reverse
 from django.conf import settings

 def absolute_redirect(url, args=None):
     """
     This is a function that I needed to make because
     Django's default redirect function doesn't work properly when
     FORCE_SCRIPT_NAME is set. It returns a full URL for redirection
     """

     reverse_url = reverse(url, args=args)

     if settings.URL_ROOT:
         reverse_url = reverse(url, args=args)
         return redirect('%s%s' % (settings.URL_ROOT, reverse_url))
     else:
         return redirect(reverse_url)
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24967>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.edeb148ea836b14671769917ead39ce1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to