HEJ!这里的许多线程都有相同的标题,但没有一个解决了我的问题.我有一个Django网站可以访问/管理员(但它看起来很难看).但在/上出现以下错误页面(DEBUG = Truein settings.py):
TemplateDoesNotExist at /
index.html
Request Method: GET
Request URL: http://iecl.uni-potsdam.de/
Django Version: 1.4.5
Exception Type: TemplateDoesNotExist
Exception Value:
index.html
Exception Location: /usr/lib/python2.7/dist-packages/django/template/loader.py in find_template, line 138
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/home/python/iecl/lib/python2.7/site-packages/distribute-0.6.28-py2.7.egg',
'/home/python/iecl/lib/python2.7/site-packages/pip-1.2.1-py2.7.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/pymodules/python2.7',
'/home/python/iecl/lib/python2.7/site-packages',
'/home/django/django']
Server time: Mon, 7 Apr 2014 11:28:46 +0200
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/django/django/templates/iecl_dev/index.html (File does not exist)
Using …Run Code Online (Sandbox Code Playgroud) 尝试转到我的Django应用程序的管理面板时出现此错误:
在/admin/index.html上的TemplateDoesNotExist
例外位置:/home/mhb11/.virtualenvs/redditpk/local/lib/python2.7/site-packages/django/template/loader.py in find_template,139行
模板加载器postmortem Django尝试按以下顺序加载这些模板:使用loader django.template.loaders.filesystem.Loader:使用loader django.template.loaders.app_directories.Loader:/ home/mhb11/folder/project/templates/admin /index.html(文件不存在)/home/mhb11/.virtualenvs/projectenv/local/lib/python2.7/site-packages/bootstrap_pagination/templates/admin/index.html(文件不存在)
我有一个新的Django安装,没有移动任何文件,并且django.contrib.admin在INSTALLED_APPS中添加了settings.py .
如果我去,/.virtualenvs/projectenv/local/lib/python2.7/site-packages/django/contrib/admin/我没有找到一个/templates/文件夹(其中包含index.html和一堆其他文件).
但是,安装在不同机器上的完全相同的项目是否具有该/templates/文件夹.我在我的虚拟环境中卸载并重新安装了Django,但无济于事.
在settings.py中安装的应用程序具有以下内容:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
#'django.contrib.sessions',
'user_sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.comments',
'myapp',
'myproject',
'south',
'registration',
'bootstrap_pagination',
'djcelery',
'tweepy',
'django.contrib.humanize',
'analytical',
'mathfilters',
#'request',
#'debug_toolbar',
#'analytical',
#'django_whoshere',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
我得到的错误的完整痕迹是:
Internal Server Error: /admin/ Traceback (most recent call last): File "/home/mhb11/.virtualenvs/projectenv/local/lib/python2.7/site-packages/django/core/handlers/base.py", …Run Code Online (Sandbox Code Playgroud) 我已经安装了jinja2,之后'DIRS'停止工作(我必须手工包含它们).改变'APP_DIRS'没有帮助
模板看起来像这样:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.jinja2.Jinja2',
'APP_DIRS': False,
'DIRS': ['main/templates', 'shop/templates'],
'OPTIONS': {
'environment': 'django_test.create_jinjia_env.environment',
'autoescape': True,
'auto_reload': DEBUG,
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Run Code Online (Sandbox Code Playgroud)
如果不在DIRS中包含模板,则会抛出相同的错误
没有找到那样的问题.提前致谢!