我一直在写我的第一个Django应用程序,遇到了使用模板的问题。
无论如何格式化模板的url,我都会收到TemplateDoesNotExist错误。
views/
核心模板是
views/template.html
myapp/views/template.html
templates/views/template.html
<full path to app>/<all variations>
我知道TEMPLATE\u DIRS变量可能在项目级别设置,但这是特定于应用程序的
视图/
目录不仅仅是模板。
我不认为我应该添加到url\u模式,因为模板不应该直接访问。
有什么建议吗?
编辑:
我的控制器中当前唯一的一行是:
template = loader.get_template("test/templates/test/template.html")
没有额外的行添加到urlpatterns,据我所知,添加到here将打开通过url对公众的访问。