在验尸中找到模板文件时出错

时间:2015-04-23 16:48:19

标签: python django django-templates

我发现了很多类似的问题,但没有人回答我的问题 似乎在 settings.py 中配置了所有内容。相关模板显示没有任何问题,但只要我添加以下行:

 {% include "{{ STATIC_URL }}angular-modules/register/register.html" %}

Django引发了TemplateDoesNotExist错误,我检查了它似乎正确的路径内容。
尸检显示如下:

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
C:\Users\Dah'\workOnPython\dynlocal_tpape\Dynlocal\templates\contrib.html (File exists)
Using loader django.template.loaders.app_directories.Loader:
C:\Users\Dah'\workOnPython\dynlocal_tpape\venv\lib\site-packages\django\contrib\admin\templates\contrib.html (File does not exist)
C:\Users\Dah'\workOnPython\dynlocal_tpape\venv\lib\site-packages\django\contrib\auth\templates\contrib.html (File does not exist)

请注意,加载程序找到该文件但不显示该文件。

这里是关注的views.py行:

def contrib(request):
    user_form = UserForm()
    return render_to_response('contrib.html',{'user_form':user_form},RequestContext(request))

1 个答案:

答案 0 :(得分:0)

删除" {{STATIC_URL}}"来自你的包括:

{% include "angular-modules/register/register.html" %}

{{ STATIC_URL }}用于提供静态文件 - 不是用于查找模板 - 并且在此上下文中(作为参数传递给模板标签的litteral字符串)不会被视为变量。

相关问题