[Django]-Heroku can't find Django templates

11👍

You’ll need to update your TEMPLATE_DIRS setting to point to something Heroku can find – the path that you have it set to right now will work locally, but Heroku has no idea where /Users/jonathanschen/ is (because it doesn’t have that folder). You might want to try making your TEMPLATE_DIRS setting use a relative path:

import os.path
PROJECT_DIR = os.path.dirname(__file__) # this is not Django setting.
TEMPLATE_DIRS = (
    os.path.join(PROJECT_DIR, "templates"),
    # here you can add another templates directory if you wish.
)

(from http://www.djangofoo.com/35/template_dirs-project-folder)

In Django 1.8+, change the DIRS option in TEMPLATES instead:

# BASE_DIR should already be in settings
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, "templates")],
        ...
    }
]

Leave a comment