在本地服务器上工作时,Heroku 上/上的 TemplateDoesNotExist

TemplateDoesNotExist at / on Heroku while working on local server

Django 和 Heroku 的新手;

我在加载页面时收到“TemplateDoesNotExist at /”。在某处读到它可能与Caps有关。

我的模板叫做templates。

在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',
        ],
    },
},

]

这是我的 views.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 即可提交。

感谢那些试图提供帮助的人。