TemplateDoesNotExist略有扭曲

时间:2015-01-25 22:35:36

标签: django python-2.7 templates

好的,因此使用django 1.5.4获取标准模板不存在错误。我很确定我已经正确设置了所有内容。 该项目为tango_with_django,其中包含名为rango的应用。然后,此应用程序将从此目录"index.html"中获取模板"C:\Users\Ryan\Documents\GitHub\tangowithdjango\tango_with_django_project\templates\rango"。 该项目是第二个文件夹,我意识到它有点乱,但第一个文件夹只包含第二个文件夹。 我的setting.py

import os 
SETTINGS_DIR = os.path.dirname(__file__) 
PROJECT_PATH = os.path.join(SETTINGS_DIR, os.pardir) 
PROJECT_PATH = os.path.abspath(PROJECT_PATH) 
TEMPLATE_PATH = os.path.join(PROJECT_PATH, 'templates') 
DEBUG = True 
TEMPLATE_DEBUG = DEBUG 
TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'django.template.loaders.eggs.Loader', ) 
TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. 
TEMPLATE_PATH, )

编辑 TemplateDoesNotExist错误也会错过dir路径中的t。不确定这只是一个显示问题,

TemplateDoesNotExist at /rango/
C:\Users\Ryan\Documents\GitHub  angowithdjango  ango_with_django_project    emplates
ango\index.html
Request Method: GET
Request URL:    http://127.0.0.1:8000/rango/
Django Version: 1.5.4
Exception Type: TemplateDoesNotExist
Exception Value:    
C:\Users\Ryan\Documents\GitHub  angowithdjango  ango_with_django_project    emplates
ango\index.html
Exception Location: C:\Python27\Lib\site-packages\django\template\loader.py in find_template, line 139
Python Executable:  C:\python27\python.exe
Python Version: 2.7.9
Python Path:    
['C:\\Users\\Ryan\\Documents\\GitHub\\tangowithdjango\\tango_with_django_project',
 'C:\\python27\\lib\\site-packages\\setuptools-1.1.6-py2.7.egg',
 'C:\\Python27\\Lib\\site-packages',
 'C:\\WINDOWS\\SYSTEM32\\python27.zip',
 'C:\\python27\\DLLs',
 'C:\\python27\\lib',
 'C:\\python27\\lib\\plat-win',
 'C:\\python27\\lib\\lib-tk',
 'C:\\python27']
Server time:    Mon, 26 Jan 2015 14:11:57 +0000

1 个答案:

答案 0 :(得分:0)

TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', # 'django.template.loaders.eggs.Loader', ) 

您已为TEMPLATE_LOADERS注释了结束括号。