简体   繁体   English

Django中的“ TemplateDoesNotExist at /”错误?

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

The server is working fine, however while using extend for this 'home.html' file unable to link the template : 服务器工作正常,但是在为该“ home.html”文件使用扩展文件时,无法链接模板:

In 'home.html': 在“ home.html”中:

{ % extends "/template1/personal/header.html" % } While loading localhost: Django tried loading these templates, in this order: {%扩展“ /template1/personal/header.html”%}在加载localhost时:Django尝试按以下顺序加载这些模板:

`Using engine django: `使用引擎django:

  1. django.template.loaders.app_directories.Loader: /usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/ffgg/home.html (Source does not exist). 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 (Source does not exist)` django.template.loaders.app_directories.Loader:/usr/local/lib/python2.7/dist-packages/django/contrib/auth/templates/ffgg/home.html(源不存在)`

1) Check what is in TEMPLATE_DIRS Variable in settings.py. 1)检查settings.py中TEMPLATE_DIRS变量中的内容。 That is the folder Django looks up in every app in order to find your template. 这是Django在每个应用程序中查找的文件夹,以查找您的模板。

2) Try remove the leading slash: 2)尝试删除斜杠:

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

3) if template1 is in TEMPLATE_DIRS, then 'app/template.html' would be enough 3)如果template1在TEMPLATE_DIRS中,那么'app / template.html'就足够了

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

Read on: 继续阅读:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM