'Production not the same as local

When running locally my files are correct but on production it seems that none of the changes are through. I might be forgetting to do something to make the production files the same as local. Changed inbox.html to another file name.

TemplateDoesNotExist at /
inbox.html
Request Method: GET
Request URL:    https://url.com/
Django Version: 3.2.9
Exception Type: TemplateDoesNotExist
Exception Value:    
inbox.html
Exception Location: /app/.heroku/python/lib/python3.9/site-packages/django/template/backends/django.py, line 84, in reraise
Python Executable:  /app/.heroku/python/bin/python
Python Version: 3.9.6
Python Path:    
['/app/.heroku/python/bin',
 '/app',
 '/app/.heroku/python/lib/python39.zip',
 '/app/.heroku/python/lib/python3.9',
 '/app/.heroku/python/lib/python3.9/lib-dynload',
 '/app/.heroku/python/lib/python3.9/site-packages']
Server time:    Tue, 01 Feb 2022 16:02:49 -0800

settings.py

"""
Django settings for portfolio project.

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

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

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

from pathlib import Path

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


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

# SECURITY WARNING: keep the secret key used in production secret!
import os

#Gets rid of 
from decouple import config


SECRET_KEY = config("SECRET_KEY")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

#DEBUG = config('DJANGO_DEBUG',default=True, cast=bool)

ALLOWED_HOSTS = ["url.com",'127.0.0.1','localhost']

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'social_django', 
    'formtools',
    'phonenumber_field',
    'pages.apps.PagesConfig',
    'storages',
    'django_cleanup.apps.CleanupConfig',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django_session_timeout.middleware.SessionTimeoutMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'social_django.middleware.SocialAuthExceptionMiddleware', #new
]

ROOT_URLCONF = 'portfolio.urls'

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',
                'social_django.context_processors.backends',  # <--
                'social_django.context_processors.login_redirect', # <--
            ],
        },
    },
]

WSGI_APPLICATION = 'portfolio.wsgi.application'

# Password validation
# https://docs.djangoproject.com/en/3.2/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/3.2/topics/i18n/


# Swapped to Canada 

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Canada/Pacific'

USE_I18N = True

USE_L10N = True

USE_TZ = False


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

# All of this is in my console.aws.amazon to configure aws s3 static files 
# If I am in prod DEBUG==false
# IAM Management Console
if DEBUG:
    AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID') 
    AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY') 
    # Amazon S3 Buckets
    AWS_STORAGE_BUCKET_NAME =  config('AWS_STORAGE_BUCKET_NAME')
    AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
    AWS_S3_OBJECT_PARAMETERS = {
        'CacheControl': 'max-age=86400',
    }
    AWS_DEFAULT_ACL = None
    AWS_S3_SIGNATURE_VERSION = 's3v4'
    AWS_S3_REGION_NAME = 'us-east-2'

    AWS_STATIC_LOCATION = 'static'
    STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, AWS_STATIC_LOCATION)
    STATICFILES_STORAGE = 'portfolio.storage_backends.StaticStorage'

    MEDIAFILES_LOCATION = 'media'
    MEDIA_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, MEDIAFILES_LOCATION )
    DEFAULT_FILE_STORAGE = 'portfolio.storage_backends.MediaStorage'

else:
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')
    STATIC_URL= '/static/'
    MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 
    MEDIA_URL = '/media/'  


STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'pages/static'),
]
# Fixes Found another file with the destination path 
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    #'django.contrib.staticfiles.finders.AppDirectoriesFinder',    #causes verbose duplicate notifications in django 1.9
)

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
#Adding social logins
AUTHENTICATION_BACKENDS = ['social_core.backends.google.GoogleOAuth2','django.contrib.auth.backends.AllowAllUsersModelBackend',]
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

# Extends default user with additional fields 

AUTH_USER_MODEL = 'pages.Profile' 
SOCIAL_AUTH_USER_MODEL = 'pages.Profile' 
# social auth configs for google
SOCIAL_AUTH_GOOGLE_OAUTH2_KEY = config('GOOGLE_OAUTH2_KEY')
SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET = config('GOOGLE_OAUTH2_SECRET')
SOCIAL_AUTH_GOOGLE_OAUTH2_SCOPE = ['https://www.googleapis.com/auth/calendar']
SOCIAL_AUTH_JSONFIELD_ENABLED = True
SOCIAL_AUTH_GOOGLE_OAUTH2_AUTH_EXTRA_ARGUMENTS = {'access_type': 'offline',}
SOCIAL_AUTH_PIPELINE = (
    'social_core.pipeline.social_auth.social_details',
    'social_core.pipeline.social_auth.social_uid',
    'social_core.pipeline.social_auth.auth_allowed',
    'social_core.pipeline.social_auth.social_user',
    'social_core.pipeline.user.get_username',
    'social_core.pipeline.social_auth.associate_by_email',  # <--- enable this one
    'social_core.pipeline.user.create_user',
    'social_core.pipeline.social_auth.associate_user',
    'social_core.pipeline.social_auth.load_extra_data',
    'social_core.pipeline.user.user_details',
) 
# Todo:Add a postgresql for prod settings using Amazon RDS Management Console

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
} 

import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)


LOGIN_URL = 'login'
LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = 'home'

SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
SESSION_ENGINE = (
    'django.contrib.sessions.backends.cache'
)
""" 
SESSION_COOKIE_AGE = 60  # change expired session

SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_SAVE_EVERY_REQUEST = True 
"""


import django_heroku
django_heroku.settings(locals(), staticfiles=False)

I changed Inbox.html to another file name but running heroku bash seems like nothing changes.

Running bash on ⬢ arundeepchohan... up, run.9168 (Free)
~ $ ls
google-credentials.json  manage.py  pages  portfolio  Procfile  Procfile.windows  requirements.txt  runtime.txt
~ $ cd pages
~/pages $ ls
admin.py  calendar.py  googleCalendarAPI.py  migrations  __pycache__  templates  urls.py
apps.py   forms.py     __init__.py           models.py   static       tests.py   views.py
~/pages $ cd templates
~/pages/templates $ ls
adminControls.html    dashboard.html        editProfileModal.html  Inbox.html         sendMessageForm.html
base.html             documents.html        googleCalendar.html    pickUserType.html  sidebar.html
bookAppointment.html  editProfileForm.html  home.html              registration
~/pages/templates $ exit
exit


Solution 1:[1]

So I added it to Github. Then I used the automatic deploy function from Heroku to connect it to that repository. Which did allow my heroku run bash to pick up the newly generated files. The only issues now are production database values are now not migrated properly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arundeep Chohan