首页 > 解决方案 > 将 Django 部署到 Heroku (TemplateDoesNotExist)

问题描述

我只是将项目部署到 Heroku,但是找不到模板。有人可以帮我吗

设置.py

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [ os.path.join(BASE_DIR,'Users/jay/Downloads/PJ/ecommerce/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',
            ],
        },
    },
]

错误信息:

异常类型:TemplateDoesNotExist 异常值:
list.html 异常位置:/app/.heroku/python/lib/python3.6/site-packages/django/template/loader.py in get_template,第 19 行 Python 可执行文件:/app/。 heroku/python/bin/python Python 版本:3.6.8 Python 路径:
['/app/.heroku/python/bin', '/app', '/app/.heroku/python/lib/python36.zip', '/app/.heroku/python/lib/python3.6', '/app/.heroku/python/lib/python3.6/lib-dynload', '/app/.heroku/python/lib/python3.6 /site-packages'] 服务器时间:Thu, 22 Aug 2019 09:51:24 +0000 Template-loader postmortem

Django 尝试按以下顺序加载这些模板:

使用引擎 django: django.template.loaders.filesystem.Loader: /app/Users/jay/Downloads/PJ/ecommerce/templates/list.html (来源不存在) django.template.loaders.app_directories.Loader: /app /.heroku/python/lib/python3.6/site-packages/django/contrib/admin/templates/list.html(源不存在)django.template.loaders.app_directories.Loader: /app/.heroku/python /lib/python3.6/site-packages/django/contrib/auth/templates/list.html(源不存在)django.template.loaders.app_directories.Loader:/app/.heroku/python/lib/python3。 6/site-packages/crispy_forms/templates/list.html(源不存在)django.template.loaders.app_directories.Loader: /app/accounts/templates/list.html(源不存在)django.template.loaders .app_directories.Loader:/app/carts/templates/list.html(源不存在)django.template.loaders。app_directories.Loader: /app/orders/templates/list.html (来源不存在) django.template.loaders.app_directories.Loader: /app/.heroku/python/lib/python3.6/site-packages/bootstrap4/模板/list.html(源不存在)

标签: pythondjango

解决方案


推荐阅读