Sorry for the long post but wanted to provide as much information as possible.
Having some serious issues trying to deploy a django app onto heroku.. Been battling for days with this.
The build is successful and so is the deployment but for some reason when navigating to the site address there is an application error.
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoProject.settings")
application = get_wsgi_application()
settings.py
import os
import dj_database_url
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
SECRET_KEY = os.environ.get('SECRET_KEY')
DEBUG = False
ALLOWED_HOSTS = []
INSTALLED_APPS = [
'blog.apps.BlogConfig',
'users.apps.UsersConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'whitenoise.storage.CompressedManifestStaticFilesStorage'
]
ROOT_URLCONF = 'djangoProject.urls'
enter code here
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',
]
WSGI_APPLICATION = 'djangoProject.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
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',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOGIN_REDIRECT_URL = 'blog-home'
LOGIN_URL = 'login'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
USE_TLS = True
Error message from logs:
2018-12-02T04:24:16.294582+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process 2018-12-02T04:24:16.294583+00:00 app[web.1]: self.load_wsgi() 2018-12-02T04:24:16.294585+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi 2018-12-02T04:24:16.294586+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2018-12-02T04:24:16.294588+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 2018-12-02T04:24:16.294590+00:00 app[web.1]: self.callable = self.load() 2018-12-02T04:24:16.294591+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load 2018-12-02T04:24:16.294593+00:00 app[web.1]: return self.load_wsgiapp() 2018-12-02T04:24:16.294594+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp 2018-12-02T04:24:16.294596+00:00 app[web.1]: return util.import_app(self.app_uri) 2018-12-02T04:24:16.294598+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app 2018-12-02T04:24:16.294599+00:00 app[web.1]: import(module) 2018-12-02T04:24:16.294601+00:00 app[web.1]: File "/app/djangoProject/wsgi.py", line 15, in 2018-12-02T04:24:16.294602+00:00 app[web.1]: application = get_wsgi_application() 2018-12-02T04:24:16.294604+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2018-12-02T04:24:16.294605+00:00 app[web.1]: django.setup(set_prefix=False) 2018-12-02T04:24:16.294607+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/init.py", line 19, in setup 2018-12-02T04:24:16.294608+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 2018-12-02T04:24:16.294610+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/init.py", line 57, in getattr 2018-12-02T04:24:16.294611+00:00 app[web.1]: self._setup(name) 2018-12-02T04:24:16.294612+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/init.py", line 44, in _setup 2018-12-02T04:24:16.294614+00:00 app[web.1]: self._wrapped = Settings(settings_module) 2018-12-02T04:24:16.294615+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/init.py", line 107, in init 2018-12-02T04:24:16.294617+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE) 2018-12-02T04:24:16.294618+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/init.py", line 127, in import_module 2018-12-02T04:24:16.294619+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2018-12-02T04:24:16.294621+00:00 app[web.1]: File "/app/djangoProject/settings.py", line 27, in 2018-12-02T04:24:16.294622+00:00 app[web.1]: DEBUG = config('DEBUG', default=False, cast=bool) 2018-12-02T04:24:16.294657+00:00 app[web.1]: NameError: name 'config' is not defined 2018-12-02T04:24:16.294918+00:00 app[web.1]: [2018-12-02 04:24:16 +0000] [10] [INFO] Worker exiting (pid: 10) 2018-12-02T04:24:16.298282+00:00 app[web.1]: [2018-12-02 04:24:16 +0000] [11] [ERROR] Exception in worker process 2018-12-02T04:24:16.298285+00:00 app[web.1]: Traceback (most recent call last): 2018-12-02T04:24:16.298287+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker 2018-12-02T04:24:16.298288+00:00 app[web.1]: worker.init_process() 2018-12-02T04:24:16.298290+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process 2018-12-02T04:24:16.298291+00:00 app[web.1]: self.load_wsgi() 2018-12-02T04:24:16.298293+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi 2018-12-02T04:24:16.298294+00:00 app[web.1]: self.wsgi = self.app.wsgi() 2018-12-02T04:24:16.298296+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi 2018-12-02T04:24:16.298298+00:00 app[web.1]: self.callable = self.load() 2018-12-02T04:24:16.298299+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load 2018-12-02T04:24:16.298301+00:00 app[web.1]: return self.load_wsgiapp() 2018-12-02T04:24:16.298302+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp 2018-12-02T04:24:16.298304+00:00 app[web.1]: return util.import_app(self.app_uri) 2018-12-02T04:24:16.298305+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app 2018-12-02T04:24:16.298307+00:00 app[web.1]: import(module) 2018-12-02T04:24:16.298308+00:00 app[web.1]: File "/app/djangoProject/wsgi.py", line 15, in 2018-12-02T04:24:16.298310+00:00 app[web.1]: application = get_wsgi_application() 2018-12-02T04:24:16.298311+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application 2018-12-02T04:24:16.298313+00:00 app[web.1]: django.setup(set_prefix=False) 2018-12-02T04:24:16.298314+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/init.py", line 19, in setup 2018-12-02T04:24:16.298316+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING) 2018-12-02T04:24:16.298317+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/init.py", line 57, in getattr 2018-12-02T04:24:16.298319+00:00 app[web.1]: self._setup(name) 2018-12-02T04:24:16.298320+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/init.py", line 44, in _setup 2018-12-02T04:24:16.298322+00:00 app[web.1]: self._wrapped = Settings(settings_module) 2018-12-02T04:24:16.298323+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/conf/init.py", line 107, in init 2018-12-02T04:24:16.298325+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE) 2018-12-02T04:24:16.298326+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/init.py", line 127, in import_module 2018-12-02T04:24:16.298328+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level) 2018-12-02T04:24:16.298329+00:00 app[web.1]: File "/app/djangoProject/settings.py", line 27, in 2018-12-02T04:24:16.298331+00:00 app[web.1]: DEBUG = config('DEBUG', default=False, cast=bool) 2018-12-02T04:24:16.298365+00:00 app[web.1]: NameError: name 'config' is not defined 2018-12-02T04:24:16.298670+00:00 app[web.1]: [2018-12-02 04:24:16 +0000] [11] [INFO] Worker exiting (pid: 11) 2018-12-02T04:24:16.379203+00:00 app[web.1]: Traceback (most recent call last): 2018-12-02T04:24:16.379212+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 210, in run 2018-12-02T04:24:16.379635+00:00 app[web.1]: self.sleep() 2018-12-02T04:24:16.379667+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 360, in sleep 2018-12-02T04:24:16.380038+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0) 2018-12-02T04:24:16.380069+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 245, in handle_chld 2018-12-02T04:24:16.380350+00:00 app[web.1]: self.reap_workers() 2018-12-02T04:24:16.380384+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 525, in reap_workers 2018-12-02T04:24:16.380791+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR) 2018-12-02T04:24:16.380959+00:00 app[web.1]: gunicorn.errors.HaltServer: 2018-12-02T04:24:16.380986+00:00 app[web.1]: 2018-12-02T04:24:16.380988+00:00 app[web.1]: During handling of the above exception, another exception occurred: 2018-12-02T04:24:16.380990+00:00 app[web.1]: 2018-12-02T04:24:16.381018+00:00 app[web.1]: Traceback (most recent call last): 2018-12-02T04:24:16.381048+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in 2018-12-02T04:24:16.381251+00:00 app[web.1]: sys.exit(run()) 2018-12-02T04:24:16.381282+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 61, in run 2018-12-02T04:24:16.381500+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() 2018-12-02T04:24:16.381539+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 223, in run 2018-12-02T04:24:16.381822+00:00 app[web.1]: super(Application, self).run() 2018-12-02T04:24:16.381852+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 72, in run 2018-12-02T04:24:16.382095+00:00 app[web.1]: Arbiter(self).run() 2018-12-02T04:24:16.382125+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 232, in run 2018-12-02T04:24:16.382399+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status) 2018-12-02T04:24:16.382428+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 345, in halt 2018-12-02T04:24:16.382782+00:00 app[web.1]: self.stop() 2018-12-02T04:24:16.382812+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 393, in stop 2018-12-02T04:24:16.383169+00:00 app[web.1]: time.sleep(0.1) 2018-12-02T04:24:16.383199+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 245, in handle_chld 2018-12-02T04:24:16.383475+00:00 app[web.1]: self.reap_workers() 2018-12-02T04:24:16.383505+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 525, in reap_workers 2018-12-02T04:24:16.383912+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR) 2018-12-02T04:24:16.384052+00:00 app[web.1]: gunicorn.errors.HaltServer: 2018-12-02T04:24:16.525711+00:00 heroku[web.1]: State changed from up to crashed 2018-12-02T04:24:16.509117+00:00 heroku[web.1]: Process exited with status 1 2018-12-02T04:26:07.329462+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=a5pire-django-framework.herokuapp.com request_id=bdd71320-3817-48e6-8667-78b6e4bc3c4b fwd="125.239.63.128" dyno= connect= service= status=503 bytes= protocol=https
Any help much appreciated. Thanks so much.