python - 在本地服务器上工作时,Heroku 上的 TemplateDoesNotExist
问题描述
Django 和 Heroku 的新手;
加载页面时,我得到“TemplateDoesNotExist at /”。在某处读过它可能与 Caps 有关。
我的模板称为模板。
在 settings.py 中:
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
print(BASE_DIR)
print(BASE_DIR / 'templates')
和
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
这是我的意见.py
from django.http import HttpResponse
from django.shortcuts import render
# Create your views here.
def homepage_view(request, *args, **kwargs):
print(args)
print(request.user)
return render(request, "homepage.html",{})
然而
在错误中,我得到:“django.template.loaders.filesystem.Loader: /app/ Templates /homepage.html(源不存在)”
即使我得到“一切都是最新的”,Heroku 似乎也没有上传我对 settings.py 所做的更改
每个人似乎都在使用 os.path.join 但我的 Pathlib 工作正常(我假设)。
在此先感谢您的帮助:)
解决方案
找到原因;
打开 VS Code 时,我无法提交更改。也许这只是关于第一次提交的事情。
现在无需关闭 VS Code 即可提交。
感谢那些试图提供帮助的人。
推荐阅读
- excel - 我需要帮助在 vba 中使用 Vlookup
- java - Javafx gui 没有出现,其他一切运行良好
- python - 如何修复 python 上的“IndexError”?
- sass - 有没有办法使用 Vuex 和中间件在 Nuxt.js 中切换全局定义的变量 scss 文件?
- css - :focus 和转置价值观 - 如何做到这一点?
- json - SQL Server 为匹配的行返回 ID 的 JSON 数组
- r - 纵向数据集中的折叠行
- java - Azure 应用服务上的 Tomcat Web-App 404-0 错误
- arrays - TensorFlow 中这个 Numpy 代码的等价物是什么?
- c# - ExecuteReader 抛出 ORA-01840 但来自 sqlDeveloper 运行良好