2

更新:见自我回答。进行更改时,我未能重新启动 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

设置.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",
)
4

1 回答 1

1

当我进行更改时,我未能重新启动 apache...我是 django 菜鸟 :)

于 2012-08-24T06:28:50.643 回答