【发布时间】:2011-06-25 22:33:22
【问题描述】:
尝试在 django 中呈现模板时收到此错误:
TemplateDoesNotExist
...
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
这是我的 settings.py 条目:
SETTINGS_PATH = os.path.normpath(os.path.dirname(__file__))
TEMPLATE_DIRS = (
os.path.join(SETTINGS_PATH, 'template'),
)
这是我的观点:
def handler(request):
if request.method == 'GET':
NewAppFormSet = modelformset_factory(Application)
return render_to_response(request, "template/apps.html",{"new_app_form":NewAppFormSet})
我已经尝试了所有可能的路径组合、调整权限等。真正的问题似乎出在模板加载器上,因为它们无法识别 TEMPLATE_DIRS 中列出的任何路径。我已经硬编码了这个字符串,但无济于事。我还使用 sudo / 作为 root 运行了 python manage.py runserver。我很茫然……
【问题讨论】:
-
碰巧
apps.html中是否有一个include模板标签引用了一个不存在的模板? -
嗯,我正在扩展另一个模板 - 我继续删除了它(以及用一些基本标记替换了整个模板),仍然没有运气。不过很好,谢谢。