Related
Build is successdul and it is producing application error, i have set up host name and debug=False as suggested but it is still causing error in opening the browser window, i am new to heroku so please suggest what needs to be done to make it work
my settings.py
"""
Django settings for djangoTut project.
Generated by 'django-admin startproject' using Django 3.2.4.
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
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
print(BASE_DIR)
# 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!
SECRET_KEY = mysecretkey
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['djangoblog-project.herokuapp.com']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog.apps.BlogConfig',
'users.apps.UsersConfig',
'crispy_forms',
]
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',
]
ROOT_URLCONF = 'djangoTut.urls'
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 = 'djangoTut.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'DATABASE' : 'DjangoProject',
'NAME': 'DjangoProject',
'USER' : 'myprojectuser',
'PASSWORD' : 'Akbar#123456',
'HOST': 'localhost',
'PORT': '',
# 'default-character-se' : 'utf8',
# 'NAME': BASE_DIR / 'db.sqlite3',
}
}
# 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/
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/3.2/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
STATICFILES_DIRS = [
]
CRISPY_TEMPLATE_PACK = 'bootstrap4'
# STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
LOGIN_REDIRECT_URL = 'blogHome'
LOGIN_URL = 'login'
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
requirements.txt for the current django project
requirements.txt
boto3==1.9.96
botocore==1.12.96
certifi==2018.10.15
chardet==3.0.4
dj-database-url==0.5.0
Django==2.1
django-crispy-forms==1.7.2
django-heroku==0.3.1
django-storages==1.7.1
docutils==0.14
gunicorn==19.9.0
idna==2.7
jmespath==0.9.3
Pillow==5.2.0
python-dateutil==2.8.0
pytz==2018.5
requests==2.19.1
s3transfer==0.2.0
six==1.12.0
urllib3==1.23
whitenoise==4.1.2
heroku logs
› Warning: heroku update available from 7.52.0 to 7.54.0.
2021-06-12T09:49:28.101517+00:00 app[web.1]: Arbiter(self).run()
2021-06-12T09:49:28.101521+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 232, in run
2021-06-12T09:49:28.101745+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2021-06-12T09:49:28.101747+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 345, in halt
2021-06-12T09:49:28.101999+00:00 app[web.1]: self.stop()
2021-06-12T09:49:28.102004+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 393, in stop
2021-06-12T09:49:28.102241+00:00 app[web.1]: time.sleep(0.1)
2021-06-12T09:49:28.102246+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2021-06-12T09:49:28.102398+00:00 app[web.1]: self.reap_workers()
2021-06-12T09:49:28.102404+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2021-06-12T09:49:28.102716+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2021-06-12T09:49:28.102754+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2021-06-12T09:49:28.205668+00:00 heroku[web.1]: Process exited with status 1
2021-06-12T09:49:28.284579+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-12T09:49:34.912538+00:00 app[api]: Release v9 created by user dhruv.singhal2612#gmail.com
2021-06-12T09:49:34.912538+00:00 app[api]: Set DEBUG_VALUE config vars by user dhruv.singhal2612#gmail.com
2021-06-12T09:49:35.143657+00:00 heroku[web.1]: State changed from crashed to starting
2021-06-12T09:49:41.619208+00:00 heroku[web.1]: Starting process with command `gunicorn django_project.wsgi`
2021-06-12T09:49:45.299640+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [4] [INFO] Starting gunicorn 19.9.0
2021-06-12T09:49:45.300103+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [4] [INFO] Listening at: http://0.0.0.0:16332 (4)
2021-06-12T09:49:45.300346+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [4] [INFO] Using worker: sync
2021-06-12T09:49:45.302082+00:00 app[web.1]: /app/.heroku/python/lib/python3.9/os.py:1023: RuntimeWarning: line buffering (buffering=1) isn't supported in binary mode, the default buffer size will be used
2021-06-12T09:49:45.302083+00:00 app[web.1]: return io.open(fd, *args, **kwargs)
2021-06-12T09:49:45.306106+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [7] [INFO] Booting worker with pid: 7
2021-06-12T09:49:45.312314+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [7] [ERROR] Exception in worker process
2021-06-12T09:49:45.312315+00:00 app[web.1]: Traceback (most recent call last):
2021-06-12T09:49:45.312326+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2021-06-12T09:49:45.312326+00:00 app[web.1]: worker.init_process()
2021-06-12T09:49:45.312327+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 129, in init_process
2021-06-12T09:49:45.312328+00:00 app[web.1]: self.load_wsgi()
2021-06-12T09:49:45.312328+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2021-06-12T09:49:45.312328+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-06-12T09:49:45.312329+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-06-12T09:49:45.312329+00:00 app[web.1]: self.callable = self.load()
2021-06-12T09:49:45.312329+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2021-06-12T09:49:45.312330+00:00 app[web.1]: return self.load_wsgiapp()
2021-06-12T09:49:45.312330+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2021-06-12T09:49:45.312331+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-06-12T09:49:45.312331+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 350, in import_app
2021-06-12T09:49:45.312331+00:00 app[web.1]: __import__(module)
2021-06-12T09:49:45.312332+00:00 app[web.1]: ModuleNotFoundError: No module named 'django_project'
2021-06-12T09:49:45.312475+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [7] [INFO] Worker exiting (pid: 7)
2021-06-12T09:49:45.342275+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [8] [INFO] Booting worker with pid: 8
2021-06-12T09:49:45.354724+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [8] [ERROR] Exception in worker process
2021-06-12T09:49:45.354725+00:00 app[web.1]: Traceback (most recent call last):
2021-06-12T09:49:45.354726+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2021-06-12T09:49:45.354726+00:00 app[web.1]: worker.init_process()
2021-06-12T09:49:45.354727+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 129, in init_process
2021-06-12T09:49:45.354727+00:00 app[web.1]: self.load_wsgi()
2021-06-12T09:49:45.354728+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2021-06-12T09:49:45.354728+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2021-06-12T09:49:45.354728+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2021-06-12T09:49:45.354729+00:00 app[web.1]: self.callable = self.load()
2021-06-12T09:49:45.354729+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2021-06-12T09:49:45.354730+00:00 app[web.1]: return self.load_wsgiapp()
2021-06-12T09:49:45.354730+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2021-06-12T09:49:45.354730+00:00 app[web.1]: return util.import_app(self.app_uri)
2021-06-12T09:49:45.354731+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 350, in import_app
2021-06-12T09:49:45.354731+00:00 app[web.1]: __import__(module)
2021-06-12T09:49:45.354732+00:00 app[web.1]: ModuleNotFoundError: No module named 'django_project'
2021-06-12T09:49:45.354973+00:00 app[web.1]: [2021-06-12 09:49:45 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-06-12T09:49:45.396511+00:00 app[web.1]: Traceback (most recent call last):
2021-06-12T09:49:45.396519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 203, in run
2021-06-12T09:49:45.396872+00:00 app[web.1]: self.manage_workers()
2021-06-12T09:49:45.396873+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 545, in manage_workers
2021-06-12T09:49:45.397354+00:00 app[web.1]: self.spawn_workers()
2021-06-12T09:49:45.397381+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 617, in spawn_workers
2021-06-12T09:49:45.397935+00:00 app[web.1]: time.sleep(0.1 * random.random())
2021-06-12T09:49:45.397962+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2021-06-12T09:49:45.398390+00:00 app[web.1]: self.reap_workers()
2021-06-12T09:49:45.398463+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2021-06-12T09:49:45.398958+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2021-06-12T09:49:45.399217+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2021-06-12T09:49:45.399240+00:00 app[web.1]:
2021-06-12T09:49:45.399240+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2021-06-12T09:49:45.399241+00:00 app[web.1]:
2021-06-12T09:49:45.399265+00:00 app[web.1]: Traceback (most recent call last):
2021-06-12T09:49:45.399340+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2021-06-12T09:49:45.399650+00:00 app[web.1]: sys.exit(run())
2021-06-12T09:49:45.399677+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 61, in run
2021-06-12T09:49:45.400017+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2021-06-12T09:49:45.400048+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 223, in run
2021-06-12T09:49:45.400760+00:00 app[web.1]: super(Application, self).run()
2021-06-12T09:49:45.400788+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 72, in run
2021-06-12T09:49:45.401131+00:00 app[web.1]: Arbiter(self).run()
2021-06-12T09:49:45.401164+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 232, in run
2021-06-12T09:49:45.401541+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2021-06-12T09:49:45.401569+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 345, in halt
2021-06-12T09:49:45.402002+00:00 app[web.1]: self.stop()
2021-06-12T09:49:45.402029+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 393, in stop
2021-06-12T09:49:45.402490+00:00 app[web.1]: time.sleep(0.1)
2021-06-12T09:49:45.402519+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2021-06-12T09:49:45.403126+00:00 app[web.1]: self.reap_workers()
2021-06-12T09:49:45.403154+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2021-06-12T09:49:45.403652+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2021-06-12T09:49:45.403847+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2021-06-12T09:49:45.504630+00:00 heroku[web.1]: Process exited with status 1
2021-06-12T09:49:45.573000+00:00 heroku[web.1]: State changed from starting to crashed
2021-06-12T09:50:28.064356+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=djangoblog-project.herokuapp.com request_id=55fab425-ef64-485a-892c-cbf2120401ce fwd="223.184.234.62" dyno= connect= service= status=503 bytes= protocol=https
2021-06-12T09:50:28.695891+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=djangoblog-project.herokuapp.com request_id=2c5d885e-39a1-4683-aa17-28efabadd898 fwd="223.184.234.62" dyno= connect= service= status=503 bytes= protocol=https
If you are using django-heroku package than you have to add this in your settings.py
Add the following import statement to the top of settings.py:
import django_heroku
and Then add the following to the bottom of settings.py:
# Activate Django-Heroku.
django_heroku.settings(locals())
check official doc. https://devcenter.heroku.com/articles/django-app-configuration#settings-py-changes
Did you create the Procfile file in the project folder?
If you are using Windows PS, you can type in terminal:
echo web: gunicorn <<YOUR_PROJECT>>.wsgi --log-file - > Procfile
Another possible solution is to use Postgres instead of MySQL:
In settings.py:
DATABASES = {
'default': dj_database_url.config()
}
In requirements.txt:
psycopg2-binary==2.8.6
I was going to host it using Heroku. But it does not work because of the problem with the profile.
This my Procfile
web: gunicorn onlineMenu.wsgi --log-file -
my wsgi.py code
"""
WSGI config for onlineMenu project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'onlineMenu.settings')
application = get_wsgi_application()
this is my Heroku log (not all)
2020-10-23T16:04:08.861587+00:00 app[web.1]: Traceback (most recent
call last): 2020-10-23T16:04:08.861588+00:00 app[web.1]: File
"/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py",
line 583, in spawn_worker 2020-10-23T16:04:08.861588+00:00 app[web.1]:
worker.init_process() 2020-10-23T16:04:08.861589+00:00 app[web.1]:
File
"/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py",
line 119, in init_process 2020-10-23T16:04:08.861589+00:00 app[web.1]:
self.load_wsgi() 2020-10-23T16:04:08.861589+00:00 app[web.1]: File
"/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py",
line 144, in load_wsgi 2020-10-23T16:04:08.861590+00:00 app[web.1]:
self.wsgi = self.app.wsgi() 2020-10-23T16:04:08.861590+00:00
app[web.1]: File
"/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py",
line 67, in wsgi 2020-10-23T16:04:08.861590+00:00 app[web.1]:
self.callable = self.load() 2020-10-23T16:04:08.861591+00:00
app[web.1]: File
"/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py",
line 49, in load 2020-10-23T16:04:08.861591+00:00 app[web.1]: return
self.load_wsgiapp() 2020-10-23T16:04:08.861591+00:00 app[web.1]: File
"/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py",
line 39, in load_wsgiapp 2020-10-23T16:04:08.861592+00:00 app[web.1]:
return util.import_app(self.app_uri) 2020-10-23T16:04:08.861592+00:00
app[web.1]: File
"/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py",
line 358, in import_app 2020-10-23T16:04:08.861592+00:00 app[web.1]:
mod = importlib.import_module(module) 2020-10-23T16:04:08.861593+00:00
app[web.1]: File
"/app/.heroku/python/lib/python3.8/importlib/init.py", line 127,
in import_module 2020-10-23T16:04:08.861593+00:00 app[web.1]: return
_bootstrap._gcd_import(name[level:], package, level) 2020-10-23T16:04:08.861593+00:00 app[web.1]: File "", line 1014, in _gcd_import
2020-10-23T16:04:08.861594+00:00 app[web.1]: File "", line 991, in _find_and_load
2020-10-23T16:04:08.861594+00:00 app[web.1]: File "", line 973, in _find_and_load_unlocked
2020-10-23T16:04:08.861594+00:00 app[web.1]: ModuleNotFoundError: No
module named 'onlineMenu/wsgi' 2020-10-23T16:04:08.861841+00:00
app[web.1]: [2020-10-23 16:04:08 +0000] [10] [INFO] Worker exiting
(pid: 10) 2020-10-23T16:04:09.011977+00:00 app[web.1]: [2020-10-23
16:04:09 +0000] [4] [INFO] Shutting down: Master
2020-10-23T16:04:09.012166+00:00 app[web.1]: [2020-10-23 16:04:09
+0000] [4] [INFO] Reason: Worker failed to boot.
I know that there are a lot of questions about that, but to be honest most of them stays unanswered or the solutions do not work.
I have "simple" problem. When I set Debug to False and push it to heroku I get "Server Error (500)". I read those topics:
Heroku server error (500) when Debug = False , whitenoise could not find style.css
Whenever debug=False in django, Heroku gives Server Error (500) and when debug=True no error
https://www.reddit.com/r/djangolearning/comments/acj65x/why_am_i_getting_a_500_server_error_when/
https://teamtreehouse.com/community/heroku-bad-request-500
And I tried their solutions but it still don't work. Only solution that I didn't test and is supposed to help is to get rid of whitenoise. This one is kinda "no go" for me.
What Can I do about this error?
Thanks and Cheers!
EDIT:
Here is my log. I tried to comment out white noise but It didn't help.
I was looking in my code but I don't have any reference to "favicon.ico". Also, I tried to run collectstatic because I found some topics related to that but it didn't work for me.
First it asked me:
You have requested to collect static files at the destination
location as specified in your settings:
/app/staticfiles
And then I got error:
FileNotFoundError: [Errno 2] No such file or directory: '/app/static'
Which is weird, because first it confirmed with me that I overrited this folder from static to staticfiles. In my main directory I have folder "staticfiles". In my app folder I have folder "static". And with Debug off everything is working.
2020-05-19T05:15:40.192943+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=robotbuilder.herokuapp.com request_id=eeaf4fd1-b73b-4e84-aacd-7e701d3e8932 fwd="83.26.255.146" dyno=web.1 connect=1ms service=3ms status=404 bytes=388 protocol=http
2020-05-19T05:15:39.991705+00:00 app[web.1]: [2020-05-19 05:15:39 +0000] [11] [ERROR] Error handling request /
2020-05-19T05:15:39.991725+00:00 app[web.1]: Traceback (most recent call last):
2020-05-19T05:15:39.991726+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle
2020-05-19T05:15:39.991734+00:00 app[web.1]: self.handle_request(listener, req, client, addr)
2020-05-19T05:15:39.991734+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 175, in handle_request
2020-05-19T05:15:39.991735+00:00 app[web.1]: respiter = self.wsgi(environ, resp.start_response)
2020-05-19T05:15:39.991735+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 133, in __call__
2020-05-19T05:15:39.991735+00:00 app[web.1]: response = self.get_response(request)
2020-05-19T05:15:39.991736+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 75, in get_response
2020-05-19T05:15:39.991736+00:00 app[web.1]: response = self._middleware_chain(request)
2020-05-19T05:15:39.991736+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991737+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991739+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991740+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991741+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991741+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991741+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/whitenoise/middleware.py", line 58, in __call__
2020-05-19T05:15:39.991742+00:00 app[web.1]: response = self.get_response(request)
2020-05-19T05:15:39.991746+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991747+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991747+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991747+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991747+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991748+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991748+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__
2020-05-19T05:15:39.991748+00:00 app[web.1]: response = response or self.get_response(request)
2020-05-19T05:15:39.991748+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991749+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991749+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991749+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991750+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991750+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991750+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__
2020-05-19T05:15:39.991750+00:00 app[web.1]: response = response or self.get_response(request)
2020-05-19T05:15:39.991751+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991751+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991751+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991752+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991752+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991752+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991752+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__
2020-05-19T05:15:39.991753+00:00 app[web.1]: response = response or self.get_response(request)
2020-05-19T05:15:39.991753+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991753+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991753+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991754+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991754+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991755+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991763+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__
2020-05-19T05:15:39.991763+00:00 app[web.1]: response = response or self.get_response(request)
2020-05-19T05:15:39.991763+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991764+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991764+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991764+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991764+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991765+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991765+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__
2020-05-19T05:15:39.991765+00:00 app[web.1]: response = response or self.get_response(request)
2020-05-19T05:15:39.991765+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991766+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991766+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991766+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991766+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991767+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991767+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__
2020-05-19T05:15:39.991767+00:00 app[web.1]: response = response or self.get_response(request)
2020-05-19T05:15:39.991767+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991768+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991768+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991768+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991768+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991769+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991769+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/deprecation.py", line 94, in __call__
2020-05-19T05:15:39.991769+00:00 app[web.1]: response = response or self.get_response(request)
2020-05-19T05:15:39.991769+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991770+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991770+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991770+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991771+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991771+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991771+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/whitenoise/middleware.py", line 58, in __call__
2020-05-19T05:15:39.991771+00:00 app[web.1]: response = self.get_response(request)
2020-05-19T05:15:39.991772+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 36, in inner
2020-05-19T05:15:39.991772+00:00 app[web.1]: response = response_for_exception(request, exc)
2020-05-19T05:15:39.991772+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 90, in response_for_exception
2020-05-19T05:15:39.991772+00:00 app[web.1]: response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
2020-05-19T05:15:39.991780+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-05-19T05:15:39.991781+00:00 app[web.1]: response = get_response(request)
2020-05-19T05:15:39.991781+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 115, in _get_response
2020-05-19T05:15:39.991782+00:00 app[web.1]: response = self.process_exception_by_middleware(e, request)
2020-05-19T05:15:39.991782+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py", line 113, in _get_response
2020-05-19T05:15:39.991782+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
2020-05-19T05:15:39.991783+00:00 app[web.1]: File "/app/builder/views.py", line 8, in home
2020-05-19T05:15:39.991783+00:00 app[web.1]: return render(request, "builder/home.html")
2020-05-19T05:15:39.991783+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/shortcuts.py", line 19, in render
2020-05-19T05:15:39.991784+00:00 app[web.1]: content = loader.render_to_string(template_name, context, request, using=using)
2020-05-19T05:15:39.991790+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader.py", line 62, in render_to_string
2020-05-19T05:15:39.991790+00:00 app[web.1]: return template.render(context, request)
2020-05-19T05:15:39.991791+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
2020-05-19T05:15:39.991791+00:00 app[web.1]: return self.template.render(context)
2020-05-19T05:15:39.991791+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 171, in render
2020-05-19T05:15:39.991792+00:00 app[web.1]: return self._render(context)
2020-05-19T05:15:39.991792+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
2020-05-19T05:15:39.991792+00:00 app[web.1]: return self.nodelist.render(context)
2020-05-19T05:15:39.991792+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 936, in render
2020-05-19T05:15:39.991793+00:00 app[web.1]: bit = node.render_annotated(context)
2020-05-19T05:15:39.991793+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 903, in render_annotated
2020-05-19T05:15:39.991798+00:00 app[web.1]: return self.render(context)
2020-05-19T05:15:39.991798+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
2020-05-19T05:15:39.991798+00:00 app[web.1]: return compiled_parent._render(context)
2020-05-19T05:15:39.991799+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
2020-05-19T05:15:39.991799+00:00 app[web.1]: return self.nodelist.render(context)
2020-05-19T05:15:39.991799+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 936, in render
2020-05-19T05:15:39.991799+00:00 app[web.1]: bit = node.render_annotated(context)
2020-05-19T05:15:39.991800+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 903, in render_annotated
2020-05-19T05:15:39.991800+00:00 app[web.1]: return self.render(context)
2020-05-19T05:15:39.991800+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 106, in render
2020-05-19T05:15:39.991800+00:00 app[web.1]: url = self.url(context)
2020-05-19T05:15:39.991804+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 103, in url
2020-05-19T05:15:39.991804+00:00 app[web.1]: return self.handle_simple(path)
2020-05-19T05:15:39.991804+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 118, in handle_simple
2020-05-19T05:15:39.991805+00:00 app[web.1]: return staticfiles_storage.url(path)
2020-05-19T05:15:39.991805+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 153, in url
2020-05-19T05:15:39.991805+00:00 app[web.1]: return self._url(self.stored_name, name, force)
2020-05-19T05:15:39.991806+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 132, in _url
2020-05-19T05:15:39.991806+00:00 app[web.1]: hashed_name = hashed_name_func(*args)
2020-05-19T05:15:39.991806+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 423, in stored_name
2020-05-19T05:15:39.991806+00:00 app[web.1]: raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
2020-05-19T05:15:39.991807+00:00 app[web.1]: ValueError: Missing staticfiles manifest entry for 'builder/logo.png'
2020-05-19T05:15:39.992027+00:00 app[web.1]: 10.95.191.28 - - [19/May/2020:05:15:39 +0000] "GET / HTTP/1.1" 500 0 "-" "-"
2020-05-19T05:15:40.192825+00:00 app[web.1]: 10.95.191.28 - - [19/May/2020:05:15:40 +0000] "GET /favicon.ico HTTP/1.1" 404 179 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:76.0) Gecko/20100101 Firefox/76.0"
2020-05-19T05:15:39.996509+00:00 heroku[router]: at=info method=GET path="/" host=robotbuilder.herokuapp.com request_id=de877e93-558a-40ab-bf11-b6de261cb707 fwd="83.26.255.146" dyno=web.1 connect=1ms service=57ms status=500 bytes=244 protocol=http
EDIT2:
import os
import django_heroku
from decouple import config
import dj_database_url
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'builder',
]
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',
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
'whitenoise.middleware.WhiteNoiseMiddleware',
]
ROOT_URLCONF = 'robot_builder.urls'
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 = 'robot_builder.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
}
}
# If you want to work with your remote database on your local machine, you need to paste link from heroku lower:
# DATABASES['default'] = dj_database_url.config(default='postgres://qkwlkrkahynyik:21a1420ab5820795f3a0c736ebb607419fc7a111f093924dcfc4567dfd906b9f#ec2-54-147-209-121.compute-1.amazonaws.com:5432/d2v01dp40p4er2')
db_from_env = dj_database_url.config(conn_max_age=600)
DATABASES['default'].update(db_from_env)
# Password validation
# https://docs.djangoproject.com/en/3.0/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.0/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/3.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_TMP = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
# Debugging in heroku live
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': ('%(asctime)s [%(process)d] [%(levelname)s] ' +
'pathname=%(pathname)s lineno=%(lineno)s ' +
'funcname=%(funcName)s %(message)s'),
'datefmt': '%Y-%m-%d %H:%M:%S'
},
'simple': {
'format': '%(levelname)s %(message)s'
}
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'testlogger': {
'handlers': ['console'],
'level': 'INFO',
}
}
}
DEBUG_PROPAGATE_EXCEPTIONS = True
COMPRESS_ENABLED = os.environ.get('COMPRESS_ENABLED', False)
# Activate Django-Heroku.
django_heroku.settings(locals())
My folder structure:
robot_builder
> builder
>> migrations
>> static
>>> css
>>> builder
>>>> my images, including logo.png used as favicon
>> templates
>> models.py etc.
> media
> robot_builder
>> settings.py etc.
> staticfiles
I think I got it. The solution is working. But I think that it's also very weird. I would appreciate if someone could comment why is it like that.
You can leave whitenoise, you can make a little bit tidying up with static files dirs. Make it look like that:
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
But it isn't necessary I think. (It is also best to keep your "static" folder in your main project folder).
But The big fix is (working on django 3):
You need to run
python manage.py collectstatic
Locally ! And then submit it to heroku. And then, everything is working with Debug set to False. I tried to keep collectstatic just with .keep file. I tried to commit only .json hoping that it will be repopulated with new collectstatic files. But no. It is working only if I run collectstatic locally and then commit EVERYTHING to heroku.
If someone have more understanding of this issue and could explain it to me I would be really grateful.
In the mean time I hope that someone else will also benefit from this solution.
I found answer on this question - ValueError: Missing staticfiles manifest entry for 'favicon.ico' . Thank you very much emazzotta, also I didn't have to get rid of whitenoise and It is working in django3.
Debug your django app by logs by typing this, heroku logs --tail -a your_herokuapp_name or https://dashboard.heroku.com/apps/your_herokuapp_name/logs.
Before that add this in your settings.py:
# Debugging in heroku live
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format': ('%(asctime)s [%(process)d] [%(levelname)s] ' +
'pathname=%(pathname)s lineno=%(lineno)s ' +
'funcname=%(funcName)s %(message)s'),
'datefmt': '%Y-%m-%d %H:%M:%S'
},
'simple': {
'format': '%(levelname)s %(message)s'
}
},
'handlers': {
'null': {
'level': 'DEBUG',
'class': 'logging.NullHandler',
},
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose'
}
},
'loggers': {
'testlogger': {
'handlers': ['console'],
'level': 'INFO',
}
}
}
DEBUG_PROPAGATE_EXCEPTIONS = True
COMPRESS_ENABLED = os.environ.get('COMPRESS_ENABLED', False)
This will show you error with debug=False in heroku logs.
STACKOVERFLOW QUESTION [SOURCE]
ValueError: Missing staticfiles manifest entry for 'builder/logo.png'
It seems that in builder/staticfiles(/builder), logo.png is referenced but doesn't exist. It might be that it's trying to get to static rather than staticfiles, in which case that seems to be an internal error that would be patched out in a later version of Django. Seeing as you're using Django 2, you should probably upgrade to Django 3 if adding logo.png doesn't work.
TL;DR: Add logo.png to builder/staticfiles(/builder) or upgrade Django.
I had the same problem and in my case, I was linking to a css file that didn't exist.
For example:
{% block head %}
<link rel="stylesheet" href="{% static 'css/my-styles.css' %}">
{% endblock %}
Whereas there was actually no my-styles.css file.
I have removed the link and after that the app started to work with both settings of DEBUG (True and False).
okay so it's probably because you left out some important imports. when DEBUG = False django will not handle your static files so we need our remote server to handle that. This is the process to fix that:
go to your project directory (where manage.py exists) in your command line.
pip install whitenoise then make sure it is added to your requirements.txt by doing pip freeze > requirements.txt if this is already there's no problem.
go to your settings.py folder and locate MIDDLEWARE. add 'whitenoise.middleware.WhiteNoiseMiddleware', to it.
in the same settings.py add STATIC_ROOT = os.path.join(BASE_DIR, 'static') for my case it was just above django_heroku.settings(locals()) note: the 'static' there is just the name of the directory where your static files are stored.
now go to your wsgi.py file in the same directory as settings.py type the following at the top from whitenoise import WhiteNoise also at the bottom you will use the import so add application = WhiteNoise(application)
now change DEBUG = False and go back to the command prompt in the project directory
type python manage.py collectstatic after this a new folder will appear in the root directory of your project . Just leave it there
do git add . and git commit -m "description"
push to your remote server. for example git push heroku master for heroku
I hope this helps
I've been having some trouble getting my Django app with the django rest framework to deploy without errors to heroku. The strange thing is, there would be no issues in pushing and deploying to Heroku but would crash after deployment. Here is my file structure:
Include/
man/
Procfile/
requirements.txt
runtime.txt
Scripts/
tcl/
webadvisorapi
│ manage.py
├───src
│ │ admin.py
│ │ apps.py
│ │ models.py
│ │ serializers.py
│ │ tests.py
│ │ urls.py
│ │ views.py
│ │ __init__.py
│ │
│ ├───management
│ │ │ __init__.py
│ │ │
│ │ └───commands
│ │ runrequest.py
│ │ __init__.py
│ │
│ ├───scripts
│ request.py
│ __init__.py
│
├───static
│ .keep
│
├───staticfiles
└───webadvisorapi
│ settings.py
│ urls.py
│ wsgi.py
│ __init__.py
│
├───static
│ .keep
I have already ran this on my own machine and it worked just fine. Interestingly, my app could not be pushed and deployed to Heroku when I use any other path other than src.apps.SrcConfig in INSTALLED_APPS as it gives me the same ModuleNotFoundError. Besides that, I did get a successful deployment but the app crashed. I even cloned my project from heroku and ran my project locally and there was no issue. Here is the log from heroku logs --tail:
2019-07-13T06:43:31.172615+00:00 heroku[web.1]: Starting process with command `gunicorn webadvisorapi.webadvisorapi.wsgi --log-file -`
2019-07-13T06:43:33.243340+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [4] [INFO] Starting gunicorn 19.9.0
2019-07-13T06:43:33.243849+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [4] [INFO] Listening at: http://0.0.0.0:34512 (4)
2019-07-13T06:43:33.243940+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [4] [INFO] Using worker: sync
2019-07-13T06:43:33.249546+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [10] [INFO] Booting worker with pid: 10
2019-07-13T06:43:33.350998+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [11] [INFO] Booting worker with pid: 11
2019-07-13T06:43:33.524337+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [10] [ERROR] Exception in worker
process
2019-07-13T06:43:33.524355+00:00 app[web.1]: Traceback (most recent call last):
2019-07-13T06:43:33.524394+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-07-13T06:43:33.524397+00:00 app[web.1]: worker.init_process()
2019-07-13T06:43:33.524399+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-07-13T06:43:33.524401+00:00 app[web.1]: self.load_wsgi()
2019-07-13T06:43:33.524403+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-07-13T06:43:33.524405+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-07-13T06:43:33.524413+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-07-13T06:43:33.524415+00:00 app[web.1]: self.callable = self.load()
2019-07-13T06:43:33.524417+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-07-13T06:43:33.524419+00:00 app[web.1]: return self.load_wsgiapp()
2019-07-13T06:43:33.524421+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-07-13T06:43:33.524423+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-07-13T06:43:33.524425+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
2019-07-13T06:43:33.524426+00:00 app[web.1]: __import__(module)
2019-07-13T06:43:33.524428+00:00 app[web.1]: File "/app/webadvisorapi/webadvisorapi/wsgi.py", line 17, in
<module>
2019-07-13T06:43:33.524430+00:00 app[web.1]: application = get_wsgi_application()
2019-07-13T06:43:33.524432+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-07-13T06:43:33.524434+00:00 app[web.1]: django.setup(set_prefix=False)
2019-07-13T06:43:33.524436+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
2019-07-13T06:43:33.524438+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2019-07-13T06:43:33.524440+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate
2019-07-13T06:43:33.524442+00:00 app[web.1]: app_config = AppConfig.create(entry)
2019-07-13T06:43:33.524444+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 116, in create
2019-07-13T06:43:33.524445+00:00 app[web.1]: mod = import_module(mod_path)
2019-07-13T06:43:33.524447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2019-07-13T06:43:33.524454+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-07-13T06:43:33.524457+00:00 app[web.1]: ModuleNotFoundError: No module named 'src'
2019-07-13T06:43:33.524572+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [10] [INFO] Worker exiting (pid:
10)
2019-07-13T06:43:33.676529+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [11] [ERROR] Exception in worker
process
2019-07-13T06:43:33.676532+00:00 app[web.1]: Traceback (most recent call last):
2019-07-13T06:43:33.676535+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-07-13T06:43:33.676537+00:00 app[web.1]: worker.init_process()
2019-07-13T06:43:33.676538+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-07-13T06:43:33.676540+00:00 app[web.1]: self.load_wsgi()
2019-07-13T06:43:33.676541+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-07-13T06:43:33.676543+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-07-13T06:43:33.676545+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-07-13T06:43:33.676547+00:00 app[web.1]: self.callable = self.load()
2019-07-13T06:43:33.676549+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-07-13T06:43:33.676550+00:00 app[web.1]: return self.load_wsgiapp()
2019-07-13T06:43:33.676552+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-07-13T06:43:33.676553+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-07-13T06:43:33.676555+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app
2019-07-13T06:43:33.676556+00:00 app[web.1]: __import__(module)
2019-07-13T06:43:33.676558+00:00 app[web.1]: File "/app/webadvisorapi/webadvisorapi/wsgi.py", line 17, in
<module>
2019-07-13T06:43:33.676559+00:00 app[web.1]: application = get_wsgi_application()
2019-07-13T06:43:33.676561+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2019-07-13T06:43:33.676562+00:00 app[web.1]: django.setup(set_prefix=False)
2019-07-13T06:43:33.676564+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
2019-07-13T06:43:33.676565+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2019-07-13T06:43:33.676567+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/registry.py", line 89, in populate
2019-07-13T06:43:33.676568+00:00 app[web.1]: app_config = AppConfig.create(entry)
2019-07-13T06:43:33.676569+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/django/apps/config.py", line 116, in create
2019-07-13T06:43:33.676571+00:00 app[web.1]: mod = import_module(mod_path)
2019-07-13T06:43:33.676572+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
2019-07-13T06:43:33.676574+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2019-07-13T06:43:33.676576+00:00 app[web.1]: ModuleNotFoundError: No module named 'src'
2019-07-13T06:43:33.676797+00:00 app[web.1]: [2019-07-13 06:43:33 +0000] [11] [INFO] Worker exiting (pid:
11)
2019-07-13T06:43:33.743217+00:00 app[web.1]: Traceback (most recent call last):
2019-07-13T06:43:33.743229+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 210, in run
2019-07-13T06:43:33.743551+00:00 app[web.1]: self.sleep()
2019-07-13T06:43:33.743557+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 360, in sleep
2019-07-13T06:43:33.743786+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2019-07-13T06:43:33.743792+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2019-07-13T06:43:33.743969+00:00 app[web.1]: self.reap_workers()
2019-07-13T06:43:33.744000+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2019-07-13T06:43:33.744238+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2019-07-13T06:43:33.744322+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2019-07-13T06:43:33.744327+00:00 app[web.1]:
2019-07-13T06:43:33.744330+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2019-07-13T06:43:33.744332+00:00 app[web.1]:
2019-07-13T06:43:33.744336+00:00 app[web.1]: Traceback (most recent call last):
2019-07-13T06:43:33.744346+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 11, in <module>
2019-07-13T06:43:33.744482+00:00 app[web.1]: sys.exit(run())
2019-07-13T06:43:33.744486+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 61, in run
2019-07-13T06:43:33.744632+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2019-07-13T06:43:33.744639+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 223, in run
2019-07-13T06:43:33.744843+00:00 app[web.1]: super(Application, self).run()
2019-07-13T06:43:33.744850+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/app/base.py", line 72, in run
2019-07-13T06:43:33.744985+00:00 app[web.1]: Arbiter(self).run()
2019-07-13T06:43:33.744991+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 232, in run
2019-07-13T06:43:33.745162+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2019-07-13T06:43:33.745168+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 345, in halt
2019-07-13T06:43:33.745377+00:00 app[web.1]: self.stop()
2019-07-13T06:43:33.745411+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 393, in stop
2019-07-13T06:43:33.745611+00:00 app[web.1]: time.sleep(0.1)
2019-07-13T06:43:33.745617+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 245, in handle_chld
2019-07-13T06:43:33.745787+00:00 app[web.1]: self.reap_workers()
2019-07-13T06:43:33.745793+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.7/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2019-07-13T06:43:33.746031+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2019-07-13T06:43:33.746074+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
settings.py (I omitted things that I thought were not relevant)
import django_heroku
import dj_database_url
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'src.apps.SrcConfig',
'corsheaders',
]
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',
],
},
},
]
ROOT_URLCONF = 'webadvisorapi.urls'
WSGI_APPLICATION = 'webadvisorapi.wsgi.application'
STATIC_URL = '/static/'
django_heroku.settings(locals())
Procfile
web: gunicorn webadvisorapi.webadvisorapi.wsgi --log-file -
wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webadvisorapi.webadvisorapi.settings')
application = get_wsgi_application()
apps.py
from django.apps import AppConfig
class SrcConfig(AppConfig):
name = 'src'
webadvisorapi/urls.py
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('src.urls')),
]
I'm really not sure what the problem is here, given that this path worked fine in my localhost. I would appreciate any kind of help.
I'm using GitHub and Heroku to run my Django app. The app works as expected locally but I'm running into problems when pushing (via GitHub) it up to Heroku. I think I boiled it down to something not working with requirements.txt or the general pip set up. Specifically, I've been trying to install Django-Bootstrap4. It is in the requirements file.
I definitely don't understand this process and I very well might not even be asking the right questions. But I've tried following all of the documentation found here: https://devcenter.heroku.com/articles/python-pip.
When I'm in the virtual environment locally, everything looks fine. Then after doing:
> heroku login
> heroku run pip install django-bootstrap4 (or pip or pandas)
It seems to install, but then running:
> heroku run pip list
nothing has changed. TIA
requirements.txt
certifi==2018.8.24
chardet==3.0.4
dj-database-url==0.5.0
Django==2.1.2
django-bootstrap4==0.0.7
django-heroku==0.3.1
django-registration-redux==2.5
gunicorn==19.9.0
idna==2.7
psycopg2==2.7.5
pytz==2018.5
requests==2.19.1
urllib3==1.23
whitenoise==4.1
Pipfile
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.6"
Adding Log:
2018-11-06T02:34:49.915341+00:00 app[web.1]: Traceback (most recent call last):
2018-11-06T02:34:49.915343+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2018-11-06T02:34:49.915345+00:00 app[web.1]: worker.init_process()
2018-11-06T02:34:49.915346+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2018-11-06T02:34:49.915347+00:00 app[web.1]: self.load_wsgi()
2018-11-06T02:34:49.915349+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2018-11-06T02:34:49.915350+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-11-06T02:34:49.915351+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-11-06T02:34:49.915352+00:00 app[web.1]: self.callable = self.load()
2018-11-06T02:34:49.915354+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2018-11-06T02:34:49.915355+00:00 app[web.1]: return self.load_wsgiapp()
2018-11-06T02:34:49.915356+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2018-11-06T02:34:49.915357+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-11-06T02:34:49.915358+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2018-11-06T02:34:49.915359+00:00 app[web.1]: __import__(module)
2018-11-06T02:34:49.915360+00:00 app[web.1]: File "/app/app/wsgi.py", line 7, in <module>
2018-11-06T02:34:49.915362+00:00 app[web.1]: application = get_wsgi_application()
2018-11-06T02:34:49.915363+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2018-11-06T02:34:49.915364+00:00 app[web.1]: django.setup(set_prefix=False)
2018-11-06T02:34:49.915365+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
2018-11-06T02:34:49.915366+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2018-11-06T02:34:49.915367+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
2018-11-06T02:34:49.915368+00:00 app[web.1]: app_config = AppConfig.create(entry)
2018-11-06T02:34:49.915369+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
2018-11-06T02:34:49.915370+00:00 app[web.1]: module = import_module(entry)
2018-11-06T02:34:49.915372+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2018-11-06T02:34:49.915373+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2018-11-06T02:34:49.915426+00:00 app[web.1]: ModuleNotFoundError: No module named 'bootstrap4'
2018-11-06T02:34:49.915794+00:00 app[web.1]: [2018-11-06 02:34:49 +0000] [11] [INFO] Worker exiting (pid: 11)
2018-11-06T02:34:49.919437+00:00 app[web.1]: [2018-11-06 02:34:49 +0000] [10] [ERROR] Exception in worker process
2018-11-06T02:34:49.919439+00:00 app[web.1]: Traceback (most recent call last):
2018-11-06T02:34:49.919441+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2018-11-06T02:34:49.919443+00:00 app[web.1]: worker.init_process()
2018-11-06T02:34:49.919444+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2018-11-06T02:34:49.919446+00:00 app[web.1]: self.load_wsgi()
2018-11-06T02:34:49.919447+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2018-11-06T02:34:49.919448+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-11-06T02:34:49.919450+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-11-06T02:34:49.919451+00:00 app[web.1]: self.callable = self.load()
2018-11-06T02:34:49.919453+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2018-11-06T02:34:49.919454+00:00 app[web.1]: return self.load_wsgiapp()
2018-11-06T02:34:49.919456+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2018-11-06T02:34:49.919458+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-11-06T02:34:49.919459+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2018-11-06T02:34:49.919461+00:00 app[web.1]: __import__(module)
2018-11-06T02:34:49.919462+00:00 app[web.1]: File "/app/app/wsgi.py", line 7, in <module>
2018-11-06T02:34:49.919464+00:00 app[web.1]: application = get_wsgi_application()
2018-11-06T02:34:49.919465+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2018-11-06T02:34:49.919467+00:00 app[web.1]: django.setup(set_prefix=False)
2018-11-06T02:34:49.919469+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
2018-11-06T02:34:49.919470+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2018-11-06T02:34:49.919472+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
2018-11-06T02:34:49.919473+00:00 app[web.1]: app_config = AppConfig.create(entry)
2018-11-06T02:34:49.919474+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
2018-11-06T02:34:49.919476+00:00 app[web.1]: module = import_module(entry)
2018-11-06T02:34:49.919477+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2018-11-06T02:34:49.919479+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2018-11-06T02:34:49.919480+00:00 app[web.1]: ModuleNotFoundError: No module named 'bootstrap4'
2018-11-06T02:34:49.920093+00:00 app[web.1]: [2018-11-06 02:34:49 +0000] [10] [INFO] Worker exiting (pid: 10)
2018-11-06T02:34:50.079130+00:00 app[web.1]: [2018-11-06 02:34:50 +0000] [4] [INFO] Shutting down: Master
2018-11-06T02:34:50.079281+00:00 app[web.1]: [2018-11-06 02:34:50 +0000] [4] [INFO] Reason: Worker failed to boot.
heroku run creates an one-off Dyno and runs your command in it, your changes wouldn't be persisted.
You actually don't need to pip install yourself. Doc here
To specify Python package dependencies on Heroku via pip, add a pip
requirements file named requirements.txt to the root of your
repository.
First, run pip install django-bootstrap4
Secondly, run pip freeze > requirements.txt
Then add and commit - git add requirements.txt && git commit -m 'added django-bootstrap4 && git push heroku master
This will install the package in your Heroku app.
This solved my problem: https://stackoverflow.com/a/52821649/4490230
Something about an issue running the latest version of pipenv with pip. Specifically, I had to downgrade not only in the virtual environment but the root as well.