我试图将 \'comment.html\' 包含到 store.html 中,并 store.html 扩展 base.html。
\n\n但是 Django 抛出错误comment.html (<class \'django.template.base.TemplateDoesNotExist\'>)\n
所有模板都在同一目录中。store.html工作正常,并且可以正常扩展,base.html没有任何问题。但是,当我包含comment.html在store.html错误中时,会抛出...\n我已使用{% include "comment.html" %}它来包含comment.html到store.html
这些文件所在的目录树:\nvaibhav@ubuntu:~/TRAC/bright-coupons/brightCoupons/brightCouponsApp$ tree\n。
\n\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 __init__.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 models.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 templates\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 about.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 base.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 comment.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 contact.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 error.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 index-var.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 store.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 stores.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 submit-form.php\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 support.html\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 tags.html\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 tests.py\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 views.py\nRun Code Online (Sandbox Code Playgroud)\n
请注意,当您包含时,您必须将路径相对于模板目录的根目录。因此,如果 comment.html 位于 TEMPLATE_BASE_DIR/app/comments.html 中,您必须执行以下操作
{% include "app/comments.html" %}
Run Code Online (Sandbox Code Playgroud)
路径与包含模板的位置无关(因为包含模板可能是一个字符串......)
| 归档时间: |
|
| 查看次数: |
2061 次 |
| 最近记录: |