ModuleNotFoundError: No module named 'django_app' with heroku deployement - django

Hey mentors and senior devs
I am now on this issue 5-7 hours trying to solve it, This issue happens during the deployment of my app on digital oceans apps and these are logs that Heroku sent
please help me figure it out
2022-10-03T10:37:01.047248352Z [2022-10-03 10:37:01 +0000] [1] [INFO] Starting gunicorn 20.1.0
2022-10-03T10:37:01.048342704Z [2022-10-03 10:37:01 +0000] [1] [INFO] Listening at:
http://0.0.0.0:8080 (1)
2022-10-03T10:37:01.048420287Z [2022-10-03 10:37:01 +0000] [1] [INFO] Using worker: sync
2022-10-03T10:37:01.105225067Z [2022-10-03 10:37:01 +0000] [16] [INFO] Booting worker with
pid: 16
2022-10-03T10:37:01.121367774Z [2022-10-03 10:37:01 +0000] [16] [ERROR] Exception in worker
process
2022-10-03T10:37:01.121405181Z Traceback (most recent call last):
2022-10-03T10:37:01.121410503Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/arbiter.py", line 589, in spawn_worker
2022-10-03T10:37:01.121414404Z worker.init_process()
2022-10-03T10:37:01.121419137Z File "/workspace/.heroku/python/lib/python3.10/site-```
packages/gunicorn/workers/base.py", line 134, in init_process
2022-10-03T10:37:01.121423724Z self.load_wsgi()
2022-10-03T10:37:01.121428153Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/workers/base.py", line 146, in load_wsgi
2022-10-03T10:37:01.121431187Z self.wsgi = self.app.wsgi()
2022-10-03T10:37:01.121434180Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/app/base.py", line 67, in wsgi
2022-10-03T10:37:01.121438157Z self.callable = self.load()
2022-10-03T10:37:01.121441663Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/app/wsgiapp.py", line 58, in load
2022-10-03T10:37:01.121462270Z return self.load_wsgiapp()
2022-10-03T10:37:01.121465690Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2022-10-03T10:37:01.121469061Z return util.import_app(self.app_uri)
2022-10-03T10:37:01.121472387Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/util.py", line 359, in import_app
2022-10-03T10:37:01.121475619Z mod = importlib.import_module(module)
2022-10-03T10:37:01.121482753Z File
"/workspace/.heroku/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
2022-10-03T10:37:01.121486027Z return _bootstrap._gcd_import(name[level:], package, level)
2022-10-03T10:37:01.121490349Z File "<frozen importlib._bootstrap>", line 1050, in
_gcd_import
2022-10-03T10:37:01.121493850Z File "<frozen importlib._bootstrap>", line 1027, in
_find_and_load
2022-10-03T10:37:01.121497304Z File "<frozen importlib._bootstrap>", line 992, in
_find_and_load_unlocked
2022-10-03T10:37:01.121501773Z File "", line 241, in
_call_with_frames_removed
2022-10-03T10:37:01.121505268Z File "", line 1050, in
_gcd_import
2022-10-03T10:37:01.121508644Z File "", line 1027, in
_find_and_load
2022-10-03T10:37:01.121511905Z File "", line 1004, in
_find_and_load_unlocked
2022-10-03T10:37:01.121515248Z ModuleNotFoundError: No module named 'django_app'
2022-10-03T10:37:01.121731498Z [2022-10-03 10:37:01 +0000] [16] [INFO] Worker exiting (pid: 16)
2022-10-03T10:37:01.207224069Z [2022-10-03 10:37:01 +0000] [1] [INFO] Shutting down: Master
2022-10-03T10:37:01.207265202Z [2022-10-03 10:37:01 +0000] [1] [INFO] Reason: Worker failed to
boot.
2022-10-03T10:37:04.348012028Z [2022-10-03 10:37:04 +0000] [1] [INFO] Starting gunicorn 20.1.0
2022-10-03T10:37:04.349215146Z [2022-10-03 10:37:04 +0000] [1] [INFO] Listening at:
http://0.0.0.0:8080 (1)
2022-10-03T10:37:04.349332842Z [2022-10-03 10:37:04 +0000] [1] [INFO] Using worker: sync
2022-10-03T10:37:04.391853564Z [2022-10-03 10:37:04 +0000] [16] [INFO] Booting worker with
pid: 16
2022-10-03T10:37:04.406015762Z [2022-10-03 10:37:04 +0000] [16] [ERROR] Exception in worker
process
2022-10-03T10:37:04.406048084Z Traceback (most recent call last):
2022-10-03T10:37:04.406055314Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/arbiter.py", line 589, in spawn_worker
2022-10-03T10:37:04.406060597Z worker.init_process()
2022-10-03T10:37:04.406066330Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/workers/base.py", line 134, in init_process
2022-10-03T10:37:04.406070425Z self.load_wsgi()
2022-10-03T10:37:04.406073524Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/workers/base.py", line 146, in load_wsgi
2022-10-03T10:37:04.406075830Z self.wsgi = self.app.wsgi()
2022-10-03T10:37:04.406078174Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/app/base.py", line 67, in wsgi
2022-10-03T10:37:04.406081378Z self.callable = self.load()
2022-10-03T10:37:04.406083592Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/app/wsgiapp.py", line 58, in load
2022-10-03T10:37:04.406085923Z return self.load_wsgiapp()
2022-10-03T10:37:04.406089029Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2022-10-03T10:37:04.406091677Z return util.import_app(self.app_uri)
2022-10-03T10:37:04.406093958Z File "/workspace/.heroku/python/lib/python3.10/site-
packages/gunicorn/util.py", line 359, in import_app
2022-10-03T10:37:04.406096392Z mod = importlib.import_module(module)
2022-10-03T10:37:04.406101142Z File
"/workspace/.heroku/python/lib/python3.10/importlib/init.py", line 126, in import_module
2022-10-03T10:37:04.406103341Z return _bootstrap._gcd_import(name[level:], package, level)
2022-10-03T10:37:04.406105924Z File "", line 1050, in
_gcd_import
2022-10-03T10:37:04.406108164Z File "", line 1027, in
_find_and_load
2022-10-03T10:37:04.406110635Z File "", line 992, in
_find_and_load_unlocked
2022-10-03T10:37:04.406113766Z File "", line 241, in
_call_with_frames_removed
2022-10-03T10:37:04.406116173Z File "", line 1050, in
_gcd_import
2022-10-03T10:37:04.406118254Z File "", line 1027, in _find_and_load
2022-10-03T10:37:04.406120822Z File "", line 1004, in _find_and_load_unlocked
2022-10-03T10:37:04.406122832Z ModuleNotFoundError: No module named 'django_app'
2022-10-03T10:37:04.406270392Z [2022-10-03 10:37:04 +0000] [16] [INFO] Worker exiting (pid: 16)
2022-10-03T10:37:04.482169771Z [2022-10-03 10:37:04 +0000] [1] [INFO] Shutting down: Master
2022-10-03T10:37:04.482261239Z [2022-10-03 10:37:04 +0000] [1] [INFO] Reason: Worker failed to
boot.
in my requirements.txt
asgiref==3.4.1
beautifulsoup4==4.11.1
binary==1.0.0
dj-database-url==1.0.0
Django==3.2.15
django-bootstrap-v5==1.0.11
django-crispy-forms==1.13.0
django-heroku==0.3.1
django-request==1.6.1
gunicorn==20.1.0
importlib-metadata==4.8.3
Pillow==8.4.0
psycopg2==2.9.3
psycopg2-binary==2.9.3
python-dateutil==2.8.2
pytz==2022.2.1
six==1.16.0
soupsieve==2.3.2.post1
sqlparse==0.4.2
typing-extensions==4.1.1
whitenoise==5.3.0
zipp==3.6.0
settings
"""
from django.core.management.utils import get_random_secret_key
from pathlib import Path
import os
import sys
import dj_database_url
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", get_random_secret_key())
# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = False
DEBUG = os.getenv("DEBUG", "False") == "True"
ALLOWED_HOSTS = ['cajetan.global', 'www.cajetan.global']
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts',
'users',
'blog',
'memberships',
'dashboard',
'crispy_forms',
'bootstrap5',
]
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 = 'cajetanglobalvisas.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [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',
'blog.context_processors.add_variable_to_context',
],
},
},
]
WSGI_APPLICATION = 'cajetanglobalvisas.wsgi.application'
DEVELOPMENT_MODE = os.getenv("DEVELOPMENT_MODE", "False") == "True"
if DEVELOPMENT_MODE is True:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
if os.getenv("DATABASE_URL", None) is None:
raise Exception("DATABASE_URL environment variable not defined")
DATABASES = {
"default": dj_database_url.parse(os.environ.get("DATABASE_URL")),
}
# 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")
# STATIC_URL = '/static/'
# STATIC_ROOT = '/static/'
STATICFILES_DIRS = (os.path.join(BASE_DIR/'static'),)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_PORT = 587
# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
AUTH_USER_MODEL = 'users.User'
CRISPY_TEMPLATE_PACK= 'bootstrap4'
SITE_ID = 1
#change this in production
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = 'cajetanglobalvisa\messages'
# HTTPS settings
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_SSL_REDIRECT = True
# HSTS settings
SECURE_HSTS_SECONDS = 31536000 # 1 year
SECURE_HSTS_PRELOAD = True
SECURE_HSTS_INCLUDE_SUBDOMAINS = True

You got module not found error because you have not added your app in installed apps in settings file.
To add do the following:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'accounts',
'users',
'django_app', #added here
'blog',
'memberships',
'dashboard',
'crispy_forms',
'bootstrap5',
]

Related

I am trying to deploy django application using heroku but getting error?

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

ImportError while deploying Django app to heroku

What I am trying to do ?
I am trying to deploy my Django app to heroku.
What is the problem ?
After uploading my app to heroku. I try to access it but I get an Application Error which also mentions this command heroku logs --tail to get the details of the error. So I run the command and I get a log with the following details (It shows a lot of content in the log but I have shown only a few):
2018-08-27T20:03:18.139298+00:00 app[web.1]: [2018-08-27 20:03:18 +0000] [11] [ERROR] Exception in worker process
2018-08-27T20:03:18.139347+00:00 app[web.1]: Traceback (most recent call last):
2018-08-27T20:03:18.139351+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2018-08-27T20:03:18.139356+00:00 app[web.1]: worker.init_process()
2018-08-27T20:03:18.139358+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 129, in init_process
2018-08-27T20:03:18.139360+00:00 app[web.1]: self.load_wsgi()
2018-08-27T20:03:18.139361+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2018-08-27T20:03:18.139363+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2018-08-27T20:03:18.139365+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
2018-08-27T20:03:18.139366+00:00 app[web.1]: self.callable = self.load()
2018-08-27T20:03:18.139368+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2018-08-27T20:03:18.139370+00:00 app[web.1]: return self.load_wsgiapp()
2018-08-27T20:03:18.139371+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2018-08-27T20:03:18.139373+00:00 app[web.1]: return util.import_app(self.app_uri)
2018-08-27T20:03:18.139375+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 350, in import_app
2018-08-27T20:03:18.139377+00:00 app[web.1]: __import__(module)
2018-08-27T20:03:18.139379+00:00 app[web.1]: File "/app/ditook/wsgi.py", line 16, in <module>
2018-08-27T20:03:18.139380+00:00 app[web.1]: application = get_wsgi_application()
2018-08-27T20:03:18.139382+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
2018-08-27T20:03:18.139384+00:00 app[web.1]: django.setup(set_prefix=False)
2018-08-27T20:03:18.139385+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
2018-08-27T20:03:18.139387+00:00 app[web.1]: apps.populate(settings.INSTALLED_APPS)
2018-08-27T20:03:18.139388+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
2018-08-27T20:03:18.139390+00:00 app[web.1]: app_config = AppConfig.create(entry)
2018-08-27T20:03:18.139391+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 94, in create
2018-08-27T20:03:18.139393+00:00 app[web.1]: module = import_module(entry)
2018-08-27T20:03:18.139394+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
2018-08-27T20:03:18.139396+00:00 app[web.1]: __import__(name)
2018-08-27T20:03:18.139397+00:00 app[web.1]: ImportError: No module named django_visitor_information
Everywhere in the log I see ImportError: No module named django_visitor_information mentioned.
settings.py:
INSTALLED_APPS = [
'Authentication.apps.AuthenticationConfig',
'django_visitor_information',
...,]
MIDDLEWARE = [
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'Authentication.timezone_middleware.TimezoneMiddleware',
...,]
SETTINGS_PATH = os.path.dirname(os.path.dirname(__file__))
WSGI_APPLICATION = 'myproject.wsgi.application'
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_DIRS = [
os.path.join(BASE_DIR,"static"),
]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
MEDIA_ROOT = os.path.join(BASE_DIR, 'static/media/Img')
MEDIA_URL = '/static/media/'
project structure:
- myproject
- myproject
- migrations
- _init_.py
- admin.py
- models.py
- settings.py
- urls.py
- views.py
- wsgi.py
- static
- templates
- db.sqlite3
- GeolP.dat // this is used by django_visitor_information
- manage.py
- Procfile
- requirements.txt
- runtime.txt
I also tried to set init.py of django_visitor_information app to empty. Because I saw it in this post. But that still didn't helped.
Any help would be appreciated.

Django app only works on Debug=True Heroku

I thought I had this solved but I guess not. I've got my Django app on Heroku, and it works perfectly with DEBUG = True but does not work with DEBUG = False.
UPDATED QUESTION
Now I'm just battling with this error:
2018-03-14T18:42:08.812921+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/" host=www.powertranspro.com request_id=f75a1cec-d303-4f5c-8eee-ddf605b7c326 fwd="71.38.218.24" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=http
Would someone mind reviewing my settings files to see where I've gone wrong.
Answer
I had conflicts with whitenoise. So I went through and deleted everything that had to do with whitenoise and moved my static files to amazon S3. I am updating my code with the correct code on this post in case anyone else has a similar problem.
First my file structure:
base.py
# settings/base.py
import os
from django.utils import timezone
from decouple import config
DEBUG = config('DEBUG', cast=bool)
GOOGLE_MAPS_API_KEY = config('GOOGLE_MAPS_API_KEY')
EASY_MAPS_GOOGLE_MAPS_API_KEY = config('GOOGLE_MAPS_API_KEY')
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = 'powertrans-pro-bucket'
AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME
AWS_S3_OBJECT_PARAMETERS = {
'CacheControl': 'max-age=86400',
}
AWS_LOCATION = 'static'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'config/static'),
]
STATIC_URL = 'https://%s/%s/' % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION)
STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
DEFAULT_FILE_STORAGE = 'config.settings.storage_backends.MediaStorage'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [TEMPLATES_DIR],
'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',
'apps.todos.context_processors.todos_processor',
'apps.freight_projects.context_processors.freight_projects_processor',
],
'debug': DEBUG,
},
},
]
INSTALLED_APPS = [
'dal',
'dal_select2',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.staticfiles',
'storages',
'django_misaka',
'bootstrap3',
'localflavor',
'easy_pdf',
'django_google_maps',
'easy_maps',
'widget_tweaks',
# django-allauth
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.linkedin',
# end django all-auth
# my created apps
'apps.accounts',
'apps.user_dashboard',
'apps.customer_dashboard',
'apps.freight_projects',
'apps.todos',
'apps.locations',
'apps.loads',
'apps.project_template_tags',
'apps.quotes',
# end my created apps
]
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 = 'config.urls'
WSGI_APPLICATION = 'config.wsgi.application'
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',
},
]
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
)
# Internationalization
# https://docs.djangoproject.com/en/2.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Change 'default' database configuration with $DATABASE_URL.
#DATABASES['default'].update(dj_database_url.config(conn_max_age=500))
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Allow all host headers
SITE_ID = 1
LOGIN_REDIRECT_URL = 'login_success'
LOGOUT_REDIRECT_URL = 'logout_confirmation'
#MAILGUN SETTINGS
EMAIL_HOST = config('EMAIL_HOST')
EMAIL_PORT = config('EMAIL_PORT', cast=int)
EMAIL_HOST_USER = config('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = config('EMAIL_HOST_PASSWORD')
EMAIL_USE_TLS = config('EMAIL_USE_TLS', cast=bool)
AUTH_USER_MODEL = 'accounts.User'
production.py
# settings/production.py
from .base import *
import os
from decouple import config
import dj_database_url
DEBUG = config('DEBUG', cast=bool)
GOOGLE_MAPS_API_KEY = config('GOOGLE_MAPS_API_KEY')
SECRET_KEY = config('SECRET_KEY')
ALLOWED_HOSTS = ['shielded-tundra-23748.herokuapp.com', '.powertranspro.com']
DATABASES = {
'default': dj_database_url.config(
default=config('DATABASE_URL')
)
}
DATABASES['default']['CONN_MAX_AGE'] = 500
HEROKU LOGS
2018-03-13T21:53:23.232139+00:00 app[web.1]: [2018-03-13 21:53:23 +0000] [4] [INFO] Handling signal: term
2018-03-13T21:53:23.234260+00:00 app[web.1]: [2018-03-13 21:53:23 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-03-13T21:53:23.236062+00:00 app[web.1]: [2018-03-13 21:53:23 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-03-13T21:53:23.543646+00:00 heroku[beat.1]: Stopping all processes with SIGTERM
2018-03-13T21:53:23.575710+00:00 heroku[worker.1]: Stopping all processes with SIGTERM
2018-03-13T21:53:23.591368+00:00 app[worker.1]:
2018-03-13T21:53:23.591399+00:00 app[worker.1]: worker: Warm shutdown (MainProcess)
2018-03-13T21:53:23.749154+00:00 app[web.1]: [2018-03-13 21:53:23 +0000] [4] [INFO] Shutting down: Master
2018-03-13T21:53:24.012876+00:00 heroku[beat.1]: Process exited with status 0
2018-03-13T21:53:24.023046+00:00 heroku[web.1]: Process exited with status 0
2018-03-13T21:53:25.509937+00:00 heroku[worker.1]: Process exited with status 0
2018-03-13T21:53:43.386916+00:00 heroku[worker.1]: Starting process with command `celery -A config worker --beat`
2018-03-13T21:53:44.117616+00:00 heroku[worker.1]: State changed from starting to up
2018-03-13T21:53:45.218810+00:00 heroku[beat.1]: Starting process with command `celery -A config beat -S django`
2018-03-13T21:53:45.731767+00:00 app[worker.1]: ['/app/config/static']
2018-03-13T21:53:46.053233+00:00 heroku[beat.1]: State changed from starting to up
2018-03-13T21:53:46.582872+00:00 heroku[web.1]: Starting process with command `gunicorn config.wsgi --log-file -`
2018-03-13T21:53:47.349183+00:00 app[worker.1]:
2018-03-13T21:53:47.349228+00:00 app[worker.1]: -------------- celery#b0aaf05c-7b04-4327-9e0c-10c3fe7f2965 v4.1.0 (latentcall)
2018-03-13T21:53:47.349231+00:00 app[worker.1]: ---- **** -----
2018-03-13T21:53:47.349234+00:00 app[worker.1]: --- * *** * -- Linux-4.4.0-1012-aws-x86_64-with-debian-stretch-sid 2018-03-13 21:53:47
2018-03-13T21:53:47.349236+00:00 app[worker.1]: -- * - **** ---
2018-03-13T21:53:47.349237+00:00 app[worker.1]: - ** ---------- [config]
2018-03-13T21:53:47.349240+00:00 app[worker.1]: - ** ---------- .> app: POTRTMS:0x7f638769d7b8
2018-03-13T21:53:47.349241+00:00 app[worker.1]: - ** ---------- .> transport: redis://h:**#ec2-34-239-77-182.compute-1.amazonaws.com:53459//
2018-03-13T21:53:47.349243+00:00 app[worker.1]: - ** ---------- .> results: redis://h:**#ec2-34-239-77-182.compute-1.amazonaws.com:53459/
2018-03-13T21:53:47.349246+00:00 app[worker.1]: - *** --- * --- .> concurrency: 8 (prefork)
2018-03-13T21:53:47.349247+00:00 app[worker.1]: -- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
2018-03-13T21:53:47.349249+00:00 app[worker.1]: --- ***** -----
2018-03-13T21:53:47.349250+00:00 app[worker.1]: -------------- [queues]
2018-03-13T21:53:47.349252+00:00 app[worker.1]: .> celery exchange=celery(direct) key=celery
2018-03-13T21:53:47.349254+00:00 app[worker.1]:
2018-03-13T21:53:47.349262+00:00 app[worker.1]:
2018-03-13T21:53:47.860250+00:00 app[beat.1]: ['/app/config/static']
2018-03-13T21:53:47.881589+00:00 app[beat.1]: celery beat v4.1.0 (latentcall) is starting.
2018-03-13T21:53:49.678712+00:00 app[beat.1]: __ - ... __ - _
2018-03-13T21:53:49.678762+00:00 app[beat.1]: LocalTime -> 2018-03-13 21:53:49
2018-03-13T21:53:49.678765+00:00 app[beat.1]: Configuration ->
2018-03-13T21:53:49.678767+00:00 app[beat.1]: . broker -> redis://h:**#ec2-34-239-77-182.compute-1.amazonaws.com:53459//
2018-03-13T21:53:49.678769+00:00 app[beat.1]: . loader -> celery.loaders.app.AppLoader
2018-03-13T21:53:49.678771+00:00 app[beat.1]: . scheduler -> django_celery_beat.schedulers.DatabaseScheduler
2018-03-13T21:53:49.678773+00:00 app[beat.1]:
2018-03-13T21:53:49.678774+00:00 app[beat.1]: . logfile -> [stderr]#%WARNING
2018-03-13T21:53:49.678776+00:00 app[beat.1]: . maxinterval -> 5.00 seconds (5s)
2018-03-13T21:53:49.884036+00:00 app[web.1]: [2018-03-13 21:53:49 +0000] [4] [INFO] Starting gunicorn 19.7.1
2018-03-13T21:53:49.884609+00:00 app[web.1]: [2018-03-13 21:53:49 +0000] [4] [INFO] Listening at: http://0.0.0.0:15685 (4)
2018-03-13T21:53:49.884728+00:00 app[web.1]: [2018-03-13 21:53:49 +0000] [4] [INFO] Using worker: sync
2018-03-13T21:53:49.889062+00:00 app[web.1]: [2018-03-13 21:53:49 +0000] [8] [INFO] Booting worker with pid: 8
2018-03-13T21:53:49.892636+00:00 app[web.1]: [2018-03-13 21:53:49 +0000] [9] [INFO] Booting worker with pid: 9
2018-03-13T21:53:50.816149+00:00 heroku[web.1]: State changed from starting to up
2018-03-13T21:53:51.040875+00:00 app[web.1]: ['/app/config/static']
2018-03-13T21:53:51.180555+00:00 app[web.1]: ['/app/config/static']
2018-03-13T21:53:25+00:00 app[heroku-redis]: source=REDIS sample#active-connections=1 sample#load-avg-1m=0.08 sample#load-avg-5m=0.13 sample#load-avg-15m=0.125 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15664184kB sample#memory-free=12008784kB sample#memory-cached=1496784kB sample#memory-redis=312336bytes sample#hit-rate=0.41381 sample#evicted-keys=0
2018-03-13T21:54:20.036317+00:00 app[web.1]: [2018-03-13 21:54:20 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:8)
2018-03-13T21:54:20.036666+00:00 app[web.1]: [2018-03-13 21:54:20 +0000] [4] [CRITICAL] WORKER TIMEOUT (pid:9)
2018-03-13T21:54:20.037926+00:00 app[web.1]: [2018-03-13 21:54:20 +0000] [8] [INFO] Worker exiting (pid: 8)
2018-03-13T21:54:20.038168+00:00 app[web.1]: [2018-03-13 21:54:20 +0000] [9] [INFO] Worker exiting (pid: 9)
2018-03-13T21:54:20.337323+00:00 app[web.1]: [2018-03-13 21:54:20 +0000] [12] [INFO] Booting worker with pid: 12
2018-03-13T21:54:20.438551+00:00 app[web.1]: [2018-03-13 21:54:20 +0000] [14] [INFO] Booting worker with pid: 14
2018-03-13T21:54:20.966862+00:00 app[web.1]: ['/app/config/static']
2018-03-13T21:54:21.114239+00:00 app[web.1]: ['/app/config/static']
2018-03-13T21:54:23.414661+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=GET path="/loads/load_list/filter/" host=www.powertranspro.com request_id=912215ee-893e-431a-8849-a6cb0195ade8 fwd="71.38.218.24" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=http
Traceback
Traceback:
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
35. response = get_response(request)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
158. response = self.process_exception_by_middleware(e, request)
File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
156. response = response.render()
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/response.py" in render
106. self.content = self.rendered_content
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/response.py" in rendered_content
83. content = template.render(context, self._request)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py" in render
61. return self.template.render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in render
175. return self._render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in _render
167. return self.nodelist.render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in render
943. bit = node.render_annotated(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in render_annotated
910. return self.render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py" in render
155. return compiled_parent._render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in _render
167. return self.nodelist.render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in render
943. bit = node.render_annotated(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in render_annotated
910. return self.render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py" in render
155. return compiled_parent._render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in _render
167. return self.nodelist.render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in render
943. bit = node.render_annotated(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py" in render_annotated
910. return self.render(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py" in render
106. url = self.url(context)
File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py" in url
103. return self.handle_simple(path)
File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py" in handle_simple
118. return staticfiles_storage.url(path)
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py" in url
155. return self._url(self.stored_name, name, force)
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py" in _url
134. hashed_name = hashed_name_func(*args)
File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py" in stored_name
422. raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
Exception Type: ValueError at /loads/load_list/filter/
Exception Value: Missing staticfiles manifest entry for 'vendors/bootstrap/dist/css/bootstrap.min.css'
Request information:
From the Whitenoise Docs:
If you’re having problems with the WhiteNoise storage backend, the
chances are they’re due to the underlying Django storage engine. This
is because WhiteNoise only adds a thin wrapper around Django’s storage
to add compression support, and because the compression code is very
simple it generally doesn’t cause problems.
The most common issue is that there are CSS files which reference
other files (usually images or fonts) which don’t exist at that
specified path. When Django attempts to rewrite these references it
looks for the corresponding file and throws an error if it can’t find
it.
To test whether the problems are due to WhiteNoise or not, try
swapping the WhiteNoise storage backend for the Django one:
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
Also try python manage.py collectstatic and check if the problem still occurs.
In your project directory, where manage.py is located, will you add a static folder and put a blank human.txt file inside of it? Then do a git commit and push.

Heroku server error (500) when Debug = False , whitenoise could not find style.css

I am getting a Server Error(500) when debug is set to false, But the site works fine when debug=True
This is the Heroku log: [EDIT:NEW LOG FILE AFTER MAKING CHANGES IN DJANGO LOG]
2017-07-30T17:19:06.000000+00:00 app[api]: Build succeeded
2017-07-30T17:19:25.874517+00:00 heroku[web.1]: State changed from up to starting
2017-07-30T17:19:25.873834+00:00 heroku[web.1]: Restarting
2017-07-30T17:19:26.809034+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-07-30T17:19:26.828322+00:00 app[web.1]: [2017-07-30 17:19:26 +0000] [11] [INFO] Worker exiting (pid: 11)
2017-07-30T17:19:26.842100+00:00 app[web.1]: [2017-07-30 17:19:26 +0000] [10] [INFO] Worker exiting (pid: 10)
2017-07-30T17:19:26.852227+00:00 app[web.1]: [2017-07-30 17:19:26 +0000] [4] [INFO] Handling signal: term
2017-07-30T17:19:26.868822+00:00 app[web.1]: [2017-07-30 17:19:26 +0000] [4] [INFO] Shutting down: Master
2017-07-30T17:19:27.014793+00:00 heroku[web.1]: Process exited with status 0
2017-07-30T17:19:30.765424+00:00 heroku[web.1]: Starting process with command `gunicorn techzu.wsgi --log-file -`
2017-07-30T17:19:33.522804+00:00 app[web.1]: [2017-07-30 17:19:33 +0000] [4] [INFO] Starting gunicorn 19.7.1
2017-07-30T17:19:33.523786+00:00 app[web.1]: [2017-07-30 17:19:33 +0000] [4] [INFO] Using worker: sync
2017-07-30T17:19:33.523653+00:00 app[web.1]: [2017-07-30 17:19:33 +0000] [4] [INFO] Listening at: http://0.0.0.0:43129 (4)
2017-07-30T17:19:33.528197+00:00 app[web.1]: [2017-07-30 17:19:33 +0000] [10] [INFO] Booting worker with pid: 10
2017-07-30T17:19:33.549206+00:00 app[web.1]: [2017-07-30 17:19:33 +0000] [11] [INFO] Booting worker with pid: 11
2017-07-30T17:19:34.484665+00:00 heroku[web.1]: State changed from starting to up
2017-07-30T17:20:18.368438+00:00 heroku[router]: at=info method=GET path="/" host=www.tecbux.com request_id=84831c2e-e908-4313-8ea0-3a689a54e3a4 fwd="49.207.184.93" dyno=web.1 connect=0ms service=134ms status=500 bytes=239 protocol=http
2017-07-30T17:20:18.362963+00:00 app[web.1]: Traceback (most recent call last):
2017-07-30T17:20:18.362946+00:00 app[web.1]: Internal Server Error: /
2017-07-30T17:20:18.362964+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/exception.py", line 42, in inner
2017-07-30T17:20:18.362965+00:00 app[web.1]: response = get_response(request)
2017-07-30T17:20:18.362965+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 217, in _get_response
2017-07-30T17:20:18.362967+00:00 app[web.1]: response = self.process_exception_by_middleware(e, request)
2017-07-30T17:20:18.362967+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 215, in _get_response
2017-07-30T17:20:18.362968+00:00 app[web.1]: response = response.render()
2017-07-30T17:20:18.362969+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/response.py", line 109, in render
2017-07-30T17:20:18.362969+00:00 app[web.1]: self.content = self.rendered_content
2017-07-30T17:20:18.362972+00:00 app[web.1]: return self.template.render(context)
2017-07-30T17:20:18.362970+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/response.py", line 86, in rendered_content
2017-07-30T17:20:18.362971+00:00 app[web.1]: content = template.render(context, self._request)
2017-07-30T17:20:18.362971+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render
2017-07-30T17:20:18.362975+00:00 app[web.1]: return self.nodelist.render(context)
2017-07-30T17:20:18.362973+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 208, in render
2017-07-30T17:20:18.362973+00:00 app[web.1]: return self._render(context)
2017-07-30T17:20:18.362974+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
2017-07-30T17:20:18.362976+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 961, in render_annotated
2017-07-30T17:20:18.362978+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/templatetags/static.py", line 104, in render
2017-07-30T17:20:18.362975+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/template/base.py", line 994, in render
2017-07-30T17:20:18.362978+00:00 app[web.1]: url = self.url(context)
2017-07-30T17:20:18.362976+00:00 app[web.1]: bit = node.render_annotated(context)
2017-07-30T17:20:18.362980+00:00 app[web.1]: return self.handle_simple(path)
2017-07-30T17:20:18.362977+00:00 app[web.1]: return self.render(context)
2017-07-30T17:20:18.362981+00:00 app[web.1]: return staticfiles_storage.url(path)
2017-07-30T17:20:18.362979+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/templatetags/static.py", line 101, in url
2017-07-30T17:20:18.362981+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/templatetags/static.py", line 114, in handle_simple
2017-07-30T17:20:18.362982+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 132, in url
2017-07-30T17:20:18.362983+00:00 app[web.1]: hashed_name = self.stored_name(clean_name)
2017-07-30T17:20:18.362983+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 292, in stored_name
2017-07-30T17:20:18.362984+00:00 app[web.1]: cache_name = self.clean_name(self.hashed_name(name))
2017-07-30T17:20:18.362985+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/django/contrib/staticfiles/storage.py", line 95, in hashed_name
2017-07-30T17:20:18.362985+00:00 app[web.1]: (clean_name, self))
2017-07-30T17:20:18.362988+00:00 app[web.1]: ValueError: The file 'style.css' could not be found with <whitenoise.storage.CompressedManifestStaticFilesStorage object at 0x7f6decd24b50>.
At first i had an Internal server error, but that was because i did not put my SENDGRID API in my settings.py, After adding that i get SERVER ERROR(500)
This is the settings.py
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_HOST_USER = '****'
EMAIL_HOST_PASSWORD = '****'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_BACKEND = "sgbackend.SendGridBackend"
SENDGRID_API_KEY = "***"
ALLOWED_HOSTS = ['www.xxx.com', 'xxx.com']
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
###
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
import dj_database_url
db_from_env = dj_database_url.config()
DATABASES['default'].update(db_from_env)
MEDIA_URL = '/media/'
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_IMAGE_BACKEND = "pillow"
CKEDITOR_JQUERY_URL = '//code.jquery.com/jquery-3.1.1.min.js'
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'static/media')
The Static files are loaded in Debug=False
This is when i try heroku local web
[WARN] No ENV file found
22:19:44 web.1 | [2017-07-29 22:19:44 +0000] [7476] [INFO] Starting gunicorn 19.7.1
22:19:44 web.1 | [2017-07-29 22:19:44 +0000] [7476] [INFO] Listening at: http://0.0.0.0:5000 (7476)
22:19:44 web.1 | [2017-07-29 22:19:44 +0000] [7476] [INFO] Using worker: sync
22:19:44 web.1 | [2017-07-29 22:19:44 +0000] [7482] [INFO] Booting worker with pid: 7482
I get a BAD REQUEST (400)
PS : So,some of the images are not loading too, could this be an issue with static files? But my CSS loads along with some other images.
[EDIT]The Images That are not loading are the images i upload through django's admin page when it is live. After git push heroku master the images aren't loading.
This is my wsgi.py
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "techzu.settings")
application = get_wsgi_application()
from whitenoise.django import DjangoWhiteNoise
application = DjangoWhiteNoise(application)
[EDIT : ValueError: The file 'style.css' could not be found with .]
Added this in the settings.py
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'DEBUG'),
},
},
}
Got the errors in the log
Apparently there was a mismatch with the names of the folders in the remote server and my local machine
Try making migrations with:
heroku run python manage.py makemigrations
heroku run python manage.py migrate
I had the same issue, but this solved it.
While turning off Debugging.
You need to provide ALLOWED_HOSTS in a list. Please check Django documentation for more..
Debug = False
ALLOWED_HOSTS = ['xyz.com']
You can't use SQLite3 on Heroku. Switch to Postgres.
You need to provide ALLOWED_HOSTS
Debug = False
ALLOWED_HOSTS = [".herokuapp.com"]
And Heroku you should use PostgreSQL
https://github.com/kennethreitz/dj-database-url
In my case it was due to conflict between
django staticfiles and django _heroku staticfiles
I had to disable one of them.
Either do this,
` INSTALLED_APPS={
.
.
#django.contrib.staticfiles,
}
django_heroku.settings(locals())` #in end of settings.py
Or do this
`INSTALLED_APPS={
.
.
django.contrib.staticfiles,
}
django_heroku.settings(locals(),staticfiles=False)` #in end of settings.py
Or if you are using whitenoise ,disable staticfiles for both django and django_heroku.

Django Heroku on Windows - App crashes repeatedly

I have been trying to deploy an app to Heroku (no frills, just a simple page) but have not managed to do so. This is my log file -
2014-08-03T21:02:53.886884+00:00 heroku[web.1]: Starting process with command `gunicorn TestApp.wsgi`
2014-08-03T21:02:57.218280+00:00 heroku[web.1]: Process exited with status 3
2014-08-03T21:03:00.994045+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/"
host=fierce-oasis-7567.herokuapp.com request_id=f53c4902-5a52-4591-a099-ef006a4658d0 fwd="202.78.172.162"
dyno= connect= service= status=503 bytes=
2014-08-03T21:03:02.570801+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET
path="/favicon.ico" host=fierce-oasis-7567.herokuapp.com request_id=22872708-cf36-47b1- a5e6-552b7a1a8668
fwd="202.78.172.162" dyno= connect= service= status=503 bytes=
2014-08-03T21:14:34+00:00 heroku[slug-compiler]: Slug compilation started
2014-08-03T21:15:02+00:00 heroku[slug-compiler]: Slug compilation finished
2014-08-03T21:15:02.272206+00:00 heroku[web.1]: State changed from crashed to starting
2014-08-03T21:15:02.150270+00:00 heroku[api]: Deploy 9b69a49 by utsav.tiwary2011#gmail.com
2014-08-03T21:15:02.150376+00:00 heroku[api]: Release v8 created by utsav.tiwary2011#gmail.com
2014-08-03T21:15:06.900391+00:00 app[web.1]: Traceback (most recent call last):
2014-08-03T21:15:06.900398+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-08-03T21:15:06.885690+00:00 app[web.1]: 2014-08-03 21:15:06 [2] [INFO] Starting gunicorn 18.0
2014-08-03T21:15:06.900396+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 106, in init_process
2014-08-03T21:15:06.900402+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-08-03T21:15:06.900399+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/base.py", line 114, in wsgi
2014-08-03T21:15:06.900408+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 354, in import_app
2014-08-03T21:15:06.900404+00:00 app[web.1]: return self.load_wsgiapp()
2014-08-03T21:15:06.900411+00:00 app[web.1]: ImportError: No module named TestApp.wsgi
2014-08-03T21:15:06.900410+00:00 app[web.1]: __import__(module)
2014-08-03T21:15:06.900413+00:00 app[web.1]: Traceback (most recent call last):
2014-08-03T21:15:06.900419+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-08-03T21:15:06.900388+00:00 app[web.1]: 2014-08-03 21:15:06 [7] [ERROR] Exception in worker process:
2014-08-03T21:15:06.900406+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-08-03T21:15:06.900417+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 106, in init_process
2014-08-03T21:15:06.886483+00:00 app[web.1]: 2014-08-03 21:15:06 [2] [INFO] Listening at:
http://0.0.0.0:3589 (2)
2014-08-03T21:15:06.900427+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-08-03T21:15:06.900414+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/arbit
er.py", line 495, in spawn_worker
2014-08-03T21:15:06.900416+00:00 app[web.1]: worker.init_process()
2014-08-03T21:15:06.900393+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/arbiter.py", line 495, in spawn_worker
2014-08-03T21:15:06.900394+00:00 app[web.1]: worker.init_process()
2014-08-03T21:15:06.900420+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/base.py", line 114, in wsgi
2014-08-03T21:15:06.896296+00:00 app[web.1]: 2014-08-03 21:15:06 [7] [INFO] Booting worker with pid: 7
2014-08-03T21:15:06.900421+00:00 app[web.1]: self.callable = self.load()
2014-08-03T21:15:06.900428+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 354, in import_app
2014-08-03T21:15:06.900401+00:00 app[web.1]: self.callable = self.load()
2014-08-03T21:15:06.900407+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-08-03T21:15:06.900423+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-08-03T21:15:06.900429+00:00 app[web.1]: __import__(module)
2014-08-03T21:15:06.900431+00:00 app[web.1]: ImportError: No module named TestApp.wsgi
2014-08-03T21:15:07.024019+00:00 app[web.1]: 2014-08-03 21:15:07 [2] [INFO] Shutting down: Master
2014-08-03T21:15:06.900424+00:00 app[web.1]: return self.load_wsgiapp()
2014-08-03T21:15:07.024128+00:00 app[web.1]: 2014-08-03 21:15:07 [2] [INFO] Reason: Worker failed to boot.
2014-08-03T21:15:06.886586+00:00 app[web.1]: 2014-08-03 21:15:06 [2] [INFO] Using worker: sync
2014-08-03T21:15:06.900425+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-08-03T21:15:06.900514+00:00 app[web.1]: 2014-08-03 21:15:06 [7] [INFO] Worker exiting (pid: 7)
2014-08-03T21:15:05.633019+00:00 heroku[web.1]: Starting process with command `gunicorn TestApp.wsgi`
2014-08-03T21:15:08.072497+00:00 heroku[web.1]: Process exited with status 3
2014-08-03T21:15:08.083536+00:00 heroku[web.1]: State changed from starting to crashed
2014-08-03T21:15:08.084259+00:00 heroku[web.1]: State changed from crashed to starting
2014-08-03T21:15:11.225689+00:00 heroku[web.1]: Starting process with command `gunicorn TestApp.wsgi`
2014-08-03T21:15:12.151723+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Starting gunicorn 18.0
2014-08-03T21:15:12.166252+00:00 app[web.1]: worker.init_process()
2014-08-03T21:15:12.166257+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/base.py", line 114, in wsgi
2014-08-03T21:15:12.166251+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/arbiter.py", line 495, in spawn_worker
2014-08-03T21:15:12.166249+00:00 app[web.1]: Traceback (most recent call last):
2014-08-03T21:15:12.166260+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-08-03T21:15:12.166246+00:00 app[web.1]: 2014-08-03 21:15:12 [7] [ERROR] Exception in worker process:
2014-08-03T21:15:12.166256+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-08-03T21:15:12.166265+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-08-03T21:15:12.166259+00:00 app[web.1]: self.callable = self.load()
2014-08-03T21:15:12.166262+00:00 app[web.1]: return self.load_wsgiapp()
2014-08-03T21:15:12.166254+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 106, in init_process
2014-08-03T21:15:12.166263+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-08-03T21:15:12.166273+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/arbiter.py", line 495, i
n spawn_worker
2014-08-03T21:15:12.166271+00:00 app[web.1]: Traceback (most recent call last):
2014-08-03T21:15:12.166275+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/workers/base.py", line 106, in init_process
2014-08-03T21:15:12.166287+00:00 app[web.1]: __import__(module)
2014-08-03T21:15:12.166266+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 354, in import_app
2014-08-03T21:15:12.166281+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 62, in load
2014-08-03T21:15:12.166268+00:00 app[web.1]: __import__(module)
2014-08-03T21:15:12.166289+00:00 app[web.1]: ImportError: No module named TestApp.wsgi
2014-08-03T21:15:12.166274+00:00 app[web.1]: worker.init_process()
2014-08-03T21:15:12.166278+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/base.py", line 114, in wsgi
2014-08-03T21:15:12.166269+00:00 app[web.1]: ImportError: No module named TestApp.wsgi
2014-08-03T21:15:12.166285+00:00 app[web.1]: return util.import_app(self.app_uri)
2014-08-03T21:15:12.166283+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
2014-08-03T21:15:12.152842+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Using worker: sync
2014-08-03T21:15:12.166277+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2014-08-03T21:15:12.166282+00:00 app[web.1]: return self.load_wsgiapp()
2014-08-03T21:15:12.166279+00:00 app[web.1]: self.callable = self.load()
2014-08-03T21:15:12.152750+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Listening at:
http://0.0.0.0:28415 (2)
2014-08-03T21:15:12.287650+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Reason: Worker failed to boot.
2014-08-03T21:15:12.287529+00:00 app[web.1]: 2014-08-03 21:15:12 [2] [INFO] Shutting down: Master
2014-08-03T21:15:12.166286+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-
packages/gunicorn/util.py", line 354, in import_app
2014-08-03T21:15:12.166363+00:00 app[web.1]: 2014-08-03 21:15:12 [7] [INFO] Worker exiting (pid: 7)
2014-08-03T21:15:12.162414+00:00 app[web.1]: 2014-08-03 21:15:12 [7] [INFO] Booting worker with pid: 7
2014-08-03T21:15:15.136154+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/"
host=fierce-oasis-7567.herokuapp.com request_id=86c520f6-3c60-4817-a006-7d5111a22a3c fwd="54.83.118.7" dyno=
connect= service= status=503 bytes=
2014-08-03T21:15:13.398231+00:00 heroku[web.1]: State changed from starting to crashed
2014-08-03T21:15:13.379837+00:00 heroku[web.1]: Process exited with status 3
And this is my Procfile :
web: gunicorn TestApp.wsgi
This is my requirements.txt
Django<=1.3.1
dj-database-url==0.3.0
psycopg2==2.4.5
gunicorn==18.0
wsgiref==0.1.2
dj-static==0.0.5
static==0.4
This is my settings file:
# Django settings for TestApp project.
import os
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['*']
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_PATH, 'static'),
)
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
# Additional locations of static files
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'n(bd1f1c%e8=_xad02x5qtfn%wgwpi492e$8_erx+d)!tpeoim'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'TestApp.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'TestApp.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'gunicorn',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
import dj_database_url
DATABASES['default'] = dj_database_url.config()
Procfile : web: sh -c "cd TestApp && gunicorn TestApp.wsgi"
Basically, my error is that it is not able to locate TestApp.wsgi and hence crashes every time. I followed the following steps while deploying -
git add -A.
git commit -m"commit"
git push heroku master
git ps
Can anyone please help me figure out what is wrong ? Thanks in advance ! (Please let me know if any other file/detail
is needed)