gpt4 book ai didi

Django, TemplateDoesNotExist error : Heroku can't find template directory. 如何显示它在哪里看?

转载 作者:行者123 更新时间:2023-12-02 05:13:34 25 4
gpt4 key购买 nike

我做了很多点击和同步操作,但还没有找到解决方案。我收到此错误:

TemplateDoesNotExist at /quotes/
quotes/index.html
Request Method: GET
Request URL: http://quoteboard94.herokuapp.com/quotes/
Django Version: 1.4.4
Exception Type: TemplateDoesNotExist
Exception Value:
quotes/index.html
Exception Location: /app/.heroku/python/lib/python2.7/site-packages/django/template/loader.py in find_template, line 138
Python Executable: /app/.heroku/python/bin/python
Python Version: 2.7.3
Python Path:
['/app',
'/app/.heroku/python/lib/python2.7/site-packages/pip-1.1-py2.7.egg',
'/app',
'/app/.heroku/python/lib/python27.zip',
'/app/.heroku/python/lib/python2.7',
'/app/.heroku/python/lib/python2.7/plat-linux2',
'/app/.heroku/python/lib/python2.7/lib-tk',
'/app/.heroku/python/lib/python2.7/lib-old',
'/app/.heroku/python/lib/python2.7/lib-dynload',
'/app/.heroku/python/lib/python2.7/site-packages',
'/app/.heroku/python/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info']

我的设置是这样的:

PROJECT_DIR = os.path.dirname(__file__) #for heroku

TEMPLATE_DIRS = (
os.path.join(PROJECT_DIR, '/templates/'), # for heroku
'/Users/jacksongonzales/projects/QuoteBoard/templates/',
)

import os.path 也在顶部。

TEMPLATE_DIRS 下的路径是我的模板的绝对路径。

我是否没有为 PROJECT_DIR 和 TEMPLATE_DIRS 变量输入正确的内容?

最佳答案

我觉得应该是

os.path.join(PROJECT_DIR, 'templates'), # 用于 heroku

没有斜杠。

os.path.join(PROJECT_DIR, '/templates/'), # 用于 heroku

返回 /templates/ 不是您期望的路径

来自 docs :

If any component is an absolute path, all previous components (on Windows, including the previous drive letter, if there was one) are thrown away, and joining continues.

关于Django, TemplateDoesNotExist error : Heroku can't find template directory. 如何显示它在哪里看?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14991180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com