简体   繁体   English

为什么 Heroku 找不到我的 Django 模板?

[英]Why Heroku can't find my Django templates?

I deployed my project on Heroku.我在 Heroku 上部署了我的项目。 But it can't find my templates(Source doesn't exist):但它找不到我的模板(源不存在):

在此处输入图像描述

My project architecture:我的项目架构:

在此处输入图像描述

settings.py:设置.py:

from pathlib import Path
import sys
import os

BASE_DIR = Path(__file__).resolve().parent.parent

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

UPDATE : All templates from the Account app load with this extending更新:帐户应用程序中的所有模板都通过此扩展加载

The problem is solved.问题已经解决了。 There was extra whitespace, like {% extends 'base/base.html ' %}有额外的空格,例如{% extends 'base/base.html ' %}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM