簡體   English   中英

Django中的“ TemplateDoesNotExist at /”錯誤?

[英]'TemplateDoesNotExist at /' Error in django?

服務器工作正常,但是在為該“ home.html”文件使用擴展文件時,無法鏈接模板:

在“ home.html”中:

{%擴展“ /template1/personal/header.html”%}在加載localhost時:Django嘗試按以下順序加載這些模板:

`使用引擎django:

  1. django.template.loaders.app_directories.Loader:/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/ffgg/home.html(源不存在)。
  2. django.template.loaders.app_directories.Loader:/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/ffgg/home.html(源不存在)`

1)檢查settings.py中TEMPLATE_DIRS變量中的內容。 這是Django在每個應用程序中查找的文件夾,以查找您的模板。

2)嘗試刪除斜杠:

{% extends 'template1/personal/header.html' %}

3)如果template1在TEMPLATE_DIRS中,那么'app / template.html'就足夠了

{% extends 'personal/header.html' %}

繼續閱讀:

https://tutorial.djangogirls.org/zh-CN/template_extending/

https://docs.djangoproject.com/zh-CN/1.7/topics/templates/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM