我在现已受到攻击的服务器上有一个 Django v1.3.1 站点(以前位于 Python v2.7.3 上)。我已经能够通过旧管理站点的缓存重建大部分内容,但在新服务器实例 (Python v2.7.12) 上重新安装 Python 和 Django 后,我遇到以下错误:
TemplateDoesNotExist at /admin/
admin/login.html
Request Method: GET
Django Version: 1.3.1
Exception Type: TemplateDoesNotExist
Exception Value:
admin/login.html
Exception Location: /usr/local/lib/python2.7/dist-packages/django/template/loader.py in find_template, line 138
Python Executable: /usr/bin/python
Python Version: 2.7.12
Python Path:
['/var/django/mysite',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/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']
Server time: Sun, 15 Oct 2017 02:31:49 +0100
尝试加载模板的相关信息:
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/var/django/mysite/templates/admin/login.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
在新机器上查看 /admin/index.html 我得到:
locate admin/login.html
/usr/local/django/contrib/admin/templates/admin/login.html
在旧机器上我得到:
locate admin/login.html
/root/build/Django/build/lib.linux-x86_64-2.7/django/contrib/admin/templates/admin/login.html
/root/build/Django/django/contrib/admin/templates/admin/login.html
/root/build/Django/tests/templates/custom_admin/login.html
/usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/admin/login.html
在启动和运行这个过程中我错过了什么/在开始升级到最新的 Django 版本之前如何解决这个问题?
Edit- 内容TEMPLATE_DIRS
:
TEMPLATE_DIRS = ('/var/django/mysite/templates','C:/Users/jon/PycharmProjects/mysite/templates',)
我也有这套,所以我认为是否重要app_dir
is False
或不(?):
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)