在 post-mortem 中找到模板文件时出现错误
Error raised while template file found in post-mortem
我发现了很多类似的问题,但是 none 回答了我的问题。
在 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))
从您的包含中删除“{{ STATIC_URL }}”:
{% include "angular-modules/register/register.html" %}
{{ STATIC_URL }}
用于提供静态文件 - 不是用于查找模板 - 并且在这种情况下(作为参数传递给模板标签的垃圾字符串)无论如何都不会被视为变量。
我发现了很多类似的问题,但是 none 回答了我的问题。
在 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))
从您的包含中删除“{{ STATIC_URL }}”:
{% include "angular-modules/register/register.html" %}
{{ STATIC_URL }}
用于提供静态文件 - 不是用于查找模板 - 并且在这种情况下(作为参数传递给模板标签的垃圾字符串)无论如何都不会被视为变量。