Django 1.3.7 TemplateDoesNotExist错误admin / index.html

rum*_*i20 2 python django ubuntu

这个站点上有很多与此类似的问题,但是我找不到一个可以解释这种特殊行为的问题。

我对django和ubuntu比较陌生,所以也许解释很简单。这是我尝试迁移到新服务器的旧(v1.3.7)django项目。

这是我在apache日志中遇到的完整错误:

TemplateDoesNotExist at /admin/
admin/login.html
Request Method: GET
Request URL:    http://131.212.123.7:26080/glrimon/admin/
Django Version: 1.3.7
Exception Type: TemplateDoesNotExist
Exception Value:    
admin/login.html
Exception Location: /.../leave_beave/lib/python2.7/site-packages/django/template/loader.py in find_template, line 138
Python Executable:  /.../leave_beave/bin/python
Run Code Online (Sandbox Code Playgroud)

leave_beave 是我的virtualenv的名称。

这是回溯传递的信息:

Template-loader postmortem

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/glri_mon/siteweb/templates/admin/login.html (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
/glri_mon/siteweb/gps_upload/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/siteapp/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/glrimon_models/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/sdde/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/dv/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/contains/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/sqlwrite/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/tinymce/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/mptt/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/menus/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/text/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/picture/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/link/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/file/templates/admin/login.html (File does not exist)
/.../leave_beave/lib/python2.7/site-packages/cms/plugins/snippet/templates/admin/login.html (File does not exist)
/glri_mon/siteweb/cmsplugin_rst/templates/admin/login.html (File does not exist)
Run Code Online (Sandbox Code Playgroud)

glri_mon是django项目目录。这是相关模板的路径:/.../leave_beave/django/contrib/admin/templates/admin/index.html。关于django为什么在搜索中未包含该路径的任何想法?

这是来自settings.py的我的模板加载器:

TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)
Run Code Online (Sandbox Code Playgroud)

对于先前的问题,我也收到了同样的错误,我通过创建从有问题的模板目录(.../python2.7/site-packages/lib.../package/templates)到我的/project_dir/templates目录(这是在settings.py中配置为我的模板目录的目录)的符号链接来解决了该错误:

TEMPLATE_DIRS = (
    os.path.join(PATH, 'templates'),
) 
Run Code Online (Sandbox Code Playgroud)

当时我这样做是因为我认为这是一次性的解决方案,但是现在尝试访问我网站的管理页面时出现相同的错误(http://.../ admin /)。这告诉我我要解决这个错误。

我想我可以在每个模板目录中添加一个符号链接,以产生此错误,但这对于生产站点来说似乎不是一个好主意。

我在这里想念什么?

小智 6

较新版本的pip将为包装创建一个轮子,以加快下次使用时的安装速度。但是,由于这个原因,模板被安装到虚拟环境的根目录中。

1.4.22中添加了一种禁用车轮创建的解决方法-https: //github.com/django/django/commit/3b324970e390a6dc4c373db036d6f27300d7fded,但是在此之前的任何操作都会创建车轮文件,从而导致诸如模板丢失的问题。

车轮文件的官方支持已添加到1.5.1- https://github.com/django/django/commit/4391718f26466f82f943e37368181d5c0520fa35

对于版本19的点,您可以使用跳过车轮的安装/创建pip install --no-binary Django Django==1.3.7。较早版本的pip的命令行参数可能略有不同。