简体   繁体   中英

'TemplateDoesNotExist at /' Error in django?

The server is working fine, however while using extend for this 'home.html' file unable to link the template :

In 'home.html':

{ % extends "/template1/personal/header.html" % } While loading localhost: Django tried loading these templates, in this order:

`Using engine 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).
  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)`

1) Check what is in TEMPLATE_DIRS Variable in settings.py. That is the folder Django looks up in every app in order to find your template.

2) Try remove the leading slash:

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

3) if template1 is in TEMPLATE_DIRS, then 'app/template.html' would be enough

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

Read on:

https://tutorial.djangogirls.org/en/template_extending/

https://docs.djangoproject.com/en/1.7/topics/templates/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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