【发布时间】:2015-03-06 12:52:46
【问题描述】:
我有一个金字塔项目,其目录结构如下。在我的 views.py 中,我有这行代码指定我的模板在哪里。
@view_config(route_name='home', renderer='templates/mytemp.pt')
现在,我收到一个错误,因为它正在我的视图目录中寻找我的模板。即使我将路径指定为“demo/templates/mytemp.pt”,我也会遇到同样的错误。
ValueError: Missing template asset: demo.view:templates/mytemp.pt (/home/Demo/demo/view/templates/mytemp.pt)
这是我的目录结构:-
Demo/
|-- Demo.egg-info
`-- demo
|-- errors
|-- model
|-- scripts
|-- static
| `-- somefolder
|-- templates
|-- test
`-- view
我的 views.py 位于视图文件夹中,而 mytem.pt 位于模板文件夹中。任何帮助表示赞赏。谢谢。
【问题讨论】:
-
您可以将
../附加到renderer参数的开头吗? -
@samGbos:ValueError:缺少模板资产:demo.view:../template/mytemp.pt (/home/Demo/demo/view/../template/mytemp.pt)跨度>
-
检测错字(模板->模板S),试试
../templates/mytemp.pt -
uralbash 和 @samGbos,你们让我开心。谢谢 :) 你能把这个添加为解决方案吗?