1👍
I got the same kind of problem:
- SCRIPT_NAME defined in my apache config
- a call to
django.core.urlresolvers.reverse
outside thewsgi
didnt prepend the prefix - in any view or resource, a call to the same method prepended the prefix
I managed to have the prefix automatically prepended using the next 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 makes sure your wsgi uses your prefix every time. The second one sets the prefix, so that reverse
will find it.
Please note that you need to have the same prefix in your apache conf. It’s a bit redundant, but the cleaner fix I found.
👤mvdb
Source:stackexchange.com