我有以下目录:
项目
-
templates < - base.html位于此处
-
用户< - App
-
users / templates < - profile.html位于此处
profile.html扩展了base.html . 当我试图访问它时:
return render_to_response('profile.html', {}, context_instance=RequestContext(request))
我收到TemplateDoesNotExist异常:
异常类型:TemplateDoesNotExist异常值:profile.html
Django尝试按以下顺序加载这些模板:使用loader django.template.loaders.filesystem.Loader:使用loader django.template.loaders.app_directories.Loader:... lib / python2.7 / site-packages / django / contrib / admin / templates / profile.html(文件不存在)... lib / python2.7 / site-packages / django / contrib / auth / templates / profile.html(文件不存在)... users / templates / profile.html(文件存在)
1 回答
通过在
app/templates
目录中添加app
目录,更改templates
目录结构,即app/templates/template.html
为app/templates/app/template.html
.