开发者

Cannot extend base.html from parent directory

I have this directory structure:

root:
+pages
 -base.html
 ...
 +en
  -index.html
  .开发者_StackOverflow..
index.py
...

When I render index.html from index.py, it says it cannot find base.html.

This is the tag I used in index.html to extend base.html:

{% extends "../base.html" %}

This is the code in index.py:

path = os.path.join(os.path.dirname(__file__), 'pages/it/index.html')
        self.response.out.write(template.render(path, template_values))

Which would be the correct way? I'm using Google web app and Django templates.


You can't use paths like that in the extends tag. But you don't need to - assuming your TEMPLATE_DIRS setting is root/pages, you just do extends "base.html".


I answered a question very much like this here: TemplateDoesNotExist on python app-engine django 1.2 while template rendering relative paths

The technique demonstrated there will allow you to have full control over the directory structure in which you store your templates.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜