'''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.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Can you tell if you have the same problem setting the var to this:
{{{
FORCE_SCRIPT_NAME = "/foo/"
}}}
If this solved the problem the bug is related to the documentation.
--
Ticket URL: <https://code.djangoproject.com/ticket/24967#comment:1>
Comment (by seanherron):
The problem appears to happen with any combination of FORCE_SCRIPT_NAME
(`foo`, `/foo`, or `/foo/`). I've tested with pretty much any combination
of things I could think of, even trying with the full domain name, but
haven't been able to get around the issue.
--
Ticket URL: <https://code.djangoproject.com/ticket/24967#comment:2>
* status: new => closed
* resolution: => invalid
Comment:
Please try TicketClosingReasons/UseSupportChannels to ensure you server
setup is correct and reopen if you can say more about where the bug lies
or where the documentation could be improved. Thanks!
Your issue looks similar to: http://stackoverflow.com/questions/25289880
/django-admin-force-script-name-is-appended-twice-to-url-when-posting
--
Ticket URL: <https://code.djangoproject.com/ticket/24967#comment:3>