Django Admin - FORCE_SCRIPT_NAME is appended twice to URL when POSTing Django Admin - FORCE_SCRIPT_NAME is appended twice to URL when POSTing apache apache

Django Admin - FORCE_SCRIPT_NAME is appended twice to URL when POSTing


Is this a linux host? is it running apache, nginx? It all depends on how your web server is configured.

If you really must have a url prefix like /hub06/ then you will need to update any settings in settings.py that return a url such as LOGIN_URL, STATIC_URL, LOGIN_REDIRECT_URL etc to contain the prefix.

I don't think you need to use FORCE_SCRIPT_NAME. Comment that bit out in the settings.py and update urls.py to add the following for example:

from django.conf.urls import patterns, include, urlfrom django.contrib.auth.views import loginfrom django.contrib import adminadmin.autodiscover()urlpatterns2 = patterns('',    url(r'^$', 'yourapp.views.home', name='Home'),    url(r'^admin/', include(admin.site.urls)),)urlpatterns = patterns('',    url(r'^hub06/', include(urlpatterns2)),)

Let me know how you go.


This was the solution:

# NB - this setting is required to make the app work correctly when running# via ProxyPass from Apache. Otherwise CSRF checks and some redirects will not# work.USE_X_FORWARDED_HOST = True