My Django site is producing URLs that intermittently omit my WSGIScriptAlias. If I simply print out {% url 'index' %}
in my index.html (see my urls.py
settings below) I randomly (around 50% of the time) get either:
MySiteAlias/MySite
which is correct, or
MySite/
which is incorrect.
myapp/urls.py:
from django.conf.urls import url,include
urlpatterns = [
url(r'^MySite/', include('mysite.urls')),
]
mysite/urls.py:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
]
and views.index basically does return render(request, 'mysite/index.html)
. Any ideas on how to fix this?
I'd imagine you might have two urls with the same name, this is where namespaces will help. If you provide a namespace for your
mysite.urls
then there is no confusion on where you should go to