Reputation: 41
So after couple late night works, I finally had my app deployed onto the Heroku, but now a different issue, and sleepless night, the template does not exist
error, I'm using Django.1.11, so my setting is as following;
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'storages',
'photos',
]
and my TEMPLATES is as following, as from the doc, the installed app, with APP_DIR set to be true, would look for the templates folder within the apps.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
],
},
},
]
And finally my app structure;
|mysite
|photos
----|templates
--------|photos
------------|index.html
when I load the page, I can see from the log;
Using engine django:
django.template.loaders.app_directories.Loader: /app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/templates/photos/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /app/.heroku/python/lib/python2.7/site-packages/django/contrib/auth/templates/photos/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /app/photos/templates/photos/index.html (Source does not exist)
The last line, shows the correct path, but somehow, it cannot be found, I really dont know why, can someone shed some lights !
Thanks Jimmy
Upvotes: 2
Views: 1246
Reputation: 1110
If you want to add explicitly the path for the template folder, you can set it like this:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(BASE_DIR,'photos/templates/photos/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',
],
},
},
]
Upvotes: 2