Reputation: 1646
I have uploaded my Django project to Openshift and python code works correctly, however, my templates are being loaded from a wrong folder:
/var/lib/openshift/55b9********************/templates
My settings.py file contains:
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
)
which correctly points to
/var/lib/openshift/55b9********************/app-root/runtime/repo/wsgi/marko/templates
As shown in django's traceback page. Why could this be happening? I could copy my templates to the folder it looks for, but I'd rather not place any project files outside of the project folder. runserver
on local machine looks for templates in correct folder.
Upvotes: 1
Views: 899
Reputation: 851
Are you running Django 1.8? The TEMPLATE_DIRS
directive is deprecated and replaced by TEMPLATES
.
According to the docs you should update your settings like this:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
# insert your TEMPLATE_DIRS here
os.path.join(BASE_DIR, 'templates'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
# list if you haven't customized them:
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Assuming BASE_DIR/templates
points to the right directory.
Upvotes: 4