python - variables included in TEMPLATE_CONTEXT_PROCESSORS not in template with DEBUG=False -
when set debug=false
in settings file in django 1.5, no longer have access static_url
or of other variables should loaded template_context_processors in django templates. oddly, works when debug=true
. worth, have 'django.core.context_processors.static'
in template_context_processors
not issue. have checked few other variables in template context , none of other nothing seems there. media_url
? nope. request
? nope. see example on github (which has been updated solution), these important pieces correctly work when debug=true
, throw 500 error when debug=false
:
# settings.py django.conf.global_settings import * # ... template_context_processors += ( 'django.core.context_processors.request', ) # believe or not, 'django.core.context_processors.static' in there print template_context_processors # views.py django.template import requestcontext django.shortcuts import render_to_response def wtf(request): return render_to_response( "wtf.html", {}, context_instance=requestcontext(request) )
does special happen in django 1.5 when turn off debug mode? suggestions fixing and/or debugging problem appreciated!
looks there change between django 1.2 , 1.3.
you have include django.core.context_processors.static
in template_context_processors
if want static_url
available template outside of debug mode.
you need ensure you're using requestcontext
instance when rendering template.
Comments
Post a Comment