【发布时间】:2012-08-19 12:56:27
【问题描述】:
更新:见自我回答。进行更改时,我未能重新启动 apache。
当我尝试在生产服务器中运行我的 django 应用程序时,我收到以下关于查找模板的错误。我相信这与模板存储的位置有关;我已经更改了我的设置文件中的目录,但我想我可能错过了另一个地方。
我正在尝试查找引用“C:/django/booking/reserve”的位置,因为这是给出的路径,但我似乎无法弄清楚在哪里。有什么建议吗?
Exception Type: TemplateDoesNotExist
Exception Value: reserve/templates/index.html
Exception Location: /home/sharataka/webapps/django/lib/python2.7/django/template/loader.py in find_template, line 138
Python Path: ['/home/sharataka/webapps/django',
'/home/sharataka/webapps/django/booking',
'/home/sharataka/webapps/django/reserve',
'/home/sharataka/webapps/django/lib/python2.7',
'/home/sharataka/lib/python2.7/South-0.7.5-py2.7.egg',
'/home/sharataka/lib/python2.7/pip-1.1-py2.7.egg',
'/home/sharataka/lib/python2.7/django_debug_toolbar-0.9.4-py2.7.egg',
'/home/sharataka/lib/python2.7',
'/usr/local/lib/python27.zip',
'/usr/local/lib/python2.7',
'/usr/local/lib/python2.7/plat-linux2',
'/usr/local/lib/python2.7/lib-tk',
'/usr/local/lib/python2.7/lib-old',
'/usr/local/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages/PIL']
Django tried loading these templates, in this order:
• Using loader django.template.loaders.filesystem.Loader:
o /home/sharataka/C:/django/booking/reserve/templates/index.html (File does not exist
settings.py
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
STATIC_ROOT = '/webapps/django/'
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.
"/webapps/django",
)
【问题讨论】:
-
这是一个复制粘贴问题还是真的是一个连接路径:
/home/sharataka/C:/django/booking/reserve/templates/index.html?另外,您的设置中是否设置了TEMPLATE_DIRS变量? -
@jdi 不确定您所说的复制粘贴问题是什么意思,但我已经在 template_dirs 中包含了我所拥有的内容。我试图找出路径“C:/django/booking/reserve”可以在我的文件中引用的其他位置,因为这是我在尝试加载模板时在错误中看到的内容。
-
但我没有看到
C:/django/booking/reserve。我看到/home/sharataka/C:/django/booking/reserve/templates/index.html。什么是分隔符?这看起来像是一条路。 -
我想这是我的问题...“C:/django/booking/reserve”是从哪里来的,它是如何包含在 /home/sharataka... 路径中的?分隔符是什么意思?
-
这里还不足以知道它的真正来源。但是,是的,它向您展示了一条路径。我所说的分隔符的意思是它查看的路径不是以
C:/开头的。它以您的/home/开头。不知何故...某处...它将您的 Windows 路径与您的 linux homedir 连接起来。
标签: python django templates settings production