当我DEBUG=False
在 django 1.5 中的设置文件中进行设置时,我不再有权访问STATIC_URL
django 模板中的 TEMPLATE_CONTEXT_PROCESSORS 应该加载的或任何其他变量。奇怪的是,当DEBUG=True
. 对于它的价值,我肯定有'django.core.context_processors.static'
我的TEMPLATE_CONTEXT_PROCESSORS
所以这不是问题。我还在模板上下文中检查了其他一些变量,但似乎没有其他变量。MEDIA_URL
? 不。request
? 不。请参阅 github 上的此示例(已使用解决方案进行了更新),但这些是在以下情况下正确工作DEBUG=True
并在以下情况下引发 500 错误的重要部分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)
)
当您关闭调试模式时,django 1.5 中会发生什么特别的事情吗?任何修复和/或调试问题的建议将不胜感激!