I have the same problem:
- SCRIPT_NAME defined in my apache configuration
- calling
django.core.urlresolvers.reverse outside wsgi did not add a prefix - in any view or resource, calling the same method adds a prefix
I managed to get the prefix automatically with the following lines of code:
# in settings.py from django.core.urlresolvers import set_script_prefix ... FORCE_SCRIPT_NAME = "your-prefix" set_script_prefix(FORCE_SCRIPT_NAME) ...
The first line ensures that your wsgi will use your prefix every time. The second sets the prefix, so reverse will find it.
Note that your apache conf must have the same prefix. This is a bit redundant, but I found a fix.
source share