When I set DEBUG=False
in my settings file in django 1.5, I no longer have access to the STATIC_URL
or any of the other variables that should be loaded by my TEMPLATE_CONTEXT_PROCESSORS in my django templates. Oddly, everything works when DEBUG=True
. For what its worth, I definitely have 'django.core.context_processors.static'
in my TEMPLATE_CONTEXT_PROCESSORS
so that is not the issue. I have also checked a few other variables in my template context and none of the other nothing seems to be there. MEDIA_URL
? nope. request
? nope. See this example on github (which has been updated with solution), but these are the important pieces that correctly work when DEBUG=True
and throw a 500 error when DEBUG=False
:
# settings.py
from django.conf.global_settings import *
# ...
TEMPLATE_CONTEXT_PROCESSORS += (
'django.core.context_processors.request',
)
# believe it or not, 'django.core.context_processors.static' is in there
print TEMPLATE_CONTEXT_PROCESSORS
# views.py
from django.template import RequestContext
from django.shortcuts import render_to_response
def wtf(request):
return render_to_response(
"wtf.html", {},
context_instance=RequestContext(request)
)
Does something special happen in django 1.5 when you turn off debug mode? Any suggestions for fixing and/or debugging the problem would be greatly appreciated!