gpt4 book ai didi

python - 无法从父目录扩展 base.html

转载 作者:太空宇宙 更新时间:2023-11-03 11:35:03 25 4
gpt4 key购买 nike

我有这样的目录结构:

root:
+pages
-base.html
...
+en
-index.html
...
index.py
...

当我从 index.py 渲染 index.html 时,它说找不到 base.html。

这是我在 index.html 中用来扩展 base.html 的标签:

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

这是index.py中的代码:

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

哪个是正确的方法?我正在使用 Google 网络应用程序和 Django 模板。

最佳答案

您不能在 extends 标签中使用类似的路径。但您不需要 - 假设您的 TEMPLATE_DIRS 设置为 root/pages,您只需执行 extends "base.html"

关于python - 无法从父目录扩展 base.html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6390924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com