TemplateDoesNotExist at / base/index.html when deploying to heroku
<p>I've been working on this issue for days and I would really love some real help here! :)</p>

<p>I'm brand new to Python, Django, and stackoverflow, so please let me know if more information or a different format would be helpful. </p>

<p>I'm trying to deploy my app on Heroku. It runs locally, but when I try to </p>

<blockquote>
  <p>heroku open</p>
</blockquote>

<p>I get the following error: </p>

<blockquote>
  <p>TemplateDoesNotExist at /
  base/index.html</p>
</blockquote>

<p>I've seen this happen to others, and I've tried the following fixes which haven't worked:</p>

<ul>
<li>Changing the folder structure by putting index.html directly into templates instead of templates>base>index.html
(<a href="https://stackoverflow.com/questions/30415562/templatedoesnotexist-when-base-template-is-in-root-folder?rq=1">TemplateDoesNotExist when base template is in root folder</a>) - This causes the app to stop running locally

<ul>
<li>Adding templates as an installed app (like I did for core) by adding </li>
</ul></li>
</ul>

<blockquote>
  <p>(r'', include('templates.urls')),</p>
</blockquote>

<p>to my urls.py</p>

<p>and added </p>

<blockquote>
  <p>'templates'</p>
</blockquote>

<p>to my settings.py. This caused the app to stop running locally, so I changed it back.  </p>

<ul>
<li>changed my views.py from:</li>
</ul>

<blockquote>
<pre><code>from django.shortcuts import render from django.views.generic.base
import TemplateView
# Create your views here. class LandingView(TemplateView):
   template_name = "base/index.html"
</code></pre>
</blockquote>

<p>to</p>

<blockquote>
<pre><code>from django.shortcuts import render
from django.views.generic.base import TemplateView
# Create your views here.
class LandingView(TemplateView):  
    template_name = [os.path.join(MAIN_DIR, 'coffeedapp2/templates')],
</code></pre>
</blockquote>

<ul>
<li>checked to make sure I have standard Django 1.8x template settings (<a href="https://stackoverflow.com/questions/30018847/templatedoesnotexist-at-base-index-html">TemplateDoesNotExist at / base/index.html</a>)

<ul>
<li>tried changing my views.py from:</li>
</ul></li>
</ul>

<blockquote>
<pre><code>from django.shortcuts import render
from django.views.generic.base import TemplateView
# Create your views here.
class LandingView(TemplateView):
  template_name = "base/index.html"
</code></pre>
</blockquote>

<p>to</p>

<blockquote>
<pre><code>from django.shortcuts import render
from django.views.generic.base import TemplateView
# Create your views here.
class LandingView(TemplateView):
  template_name = "base/index.html"
</code></pre>
</blockquote>

<p>(<a href="https://stackoverflow.com/questions/36981074/templatedoesnotexist-at-at-templates-index-html">TemplateDoesNotExist at / at templates/index.html</a>)</p>

<p>I'm thinking that I may need to define a SITE_ROOT or something but whenever I try to do that it stops running locally. </p>

<p><strong>ERROR:</strong></p>

<blockquote>
  <p>TemplateDoesNotExist at / base/index.html Request Method: GET Request
  URL:  <a href="https://salty-journey-18003.herokuapp.com/" rel="nofollow noreferrer">https://salty-journey-18003.herokuapp.com/</a> Django Version:  1.9.7
  Exception Type:   TemplateDoesNotExist Exception Value:    base/index.html
  Exception
  Location: /app/.heroku/python/lib/python2.7/site-packages/django/template/loader.py
  in select_template, line 74 Python
  Executable:   /app/.heroku/python/bin/python Python Version:  2.7.12
  Python Path:   ['/app',  '/app/.heroku/python/bin', 
  '/app/.heroku/python/lib/python2.7/site-packages/setuptools-23.1.0-py2.7.egg',
  '/app/.heroku/python/lib/python2.7/site-packages/pip-8.1.2-py2.7.egg',
  '/app',  '/app/.heroku/python/lib/python27.zip', 
  '/app/.heroku/python/lib/python2.7', 
  '/app/.heroku/python/lib/python2.7/plat-linux2', 
  '/app/.heroku/python/lib/python2.7/lib-tk', 
  '/app/.heroku/python/lib/python2.7/lib-old', 
  '/app/.heroku/python/lib/python2.7/lib-dynload', 
  '/app/.heroku/python/lib/python2.7/site-packages'] Server time:   Mon, 1
  Aug 2016 20:50:53 +0000 Template-loader postmortem</p>
  
  <p>Django tried loading these templates, in this order:</p>
  
  <p>Using engine django: django.template.loaders.filesystem.Loader:
  /coffeedapp2/templates/base/index.html (Source does not exist)
  django.template.loaders.app_directories.Loader:
  /app/.heroku/python/lib/python2.7/site-packages/django/contrib/admin/templates/base/index.html
  (Source does not exist)
  django.template.loaders.app_directories.Loader:
  /app/.heroku/python/lib/python2.7/site-packages/django/contrib/auth/templates/base/index.html
  (Source does not exist)</p>
</blockquote>

<p>settings.py</p>

<p>"""</p>

<pre><code>Django settings for coffeedapp2 project.

Generated by 'django-admin startproject' using Django 1.9.7.

For more information on this file, see
https://docs.djangoproject.com/en/1.9/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
MAIN_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))



# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '^h)ohz4qbhu&amp;5po084_ob8qy+1c*h^tb#jtab!p965^8@&amp;64q!'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'core',
]

MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'coffeedapp2.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(MAIN_DIR, 'coffeedapp2/templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                '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',
            ],
        },
    },
]

WSGI_APPLICATION = 'coffeedapp2.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.9/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Update database configuration with $DATABASE_URL.
import dj_database_url
db_from_env = dj_database_url.config()
DATABASES['default'] = dj_database_url.config()

# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')

# Allow all host headers
ALLOWED_HOSTS = ['*']


# Password validation
# https://docs.djangoproject.com/en/1.9/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/1.9/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.9/howto/static-files/

STATIC_URL = '/static/'


STATICFILES_DIRS = (
    os.path.join(MAIN_DIR, 'coffeedapp2', 'static'),
    )
</code></pre>

<p>coffeedapp>urls.py</p>

<pre><code>from django.conf.urls import url
from django.contrib import admin
from django.conf.urls import include
from django.conf.urls import patterns

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)),
    (r'', include('core.urls')),
)
</code></pre>

<p>core>urls.py</p>

<pre><code>from django.conf.urls import patterns, include, url
import core.views as coreviews
from django.conf.urls import include

urlpatterns = patterns('',

    url(r'^$', coreviews.LandingView.as_view()),
 )
</code></pre>

<p>core>views.py</p>

<pre><code>from django.shortcuts import render
from django.views.generic.base import TemplateView
# Create your views here.
class LandingView(TemplateView):
    template_name = "base/index.html"
</code></pre>

<p><a href="https://i.stack.imgur.com/45NUY.png" rel="nofollow noreferrer">See image of file structure</a></p>

<pre><code>Relevant file structure:

coffeedapp2
  coffeedapp2
    _init_.py
    settings.py
    settings.py
    urls.py
    wsgi.py
  core
    migrations
    _init_.py
    admin.py
    apps.py
    models.py
    tests.py
    urls.py
    views.py
  static
  templates
    base
        index.html
</code></pre>