Django app only works on Debug=True Heroku - django

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.

Related

ModuleNotFoundError: No module named 'django_app' with heroku deployement

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',
]

Why am I getting a server (500) error when Debug=False in Django for Heroku?

So, I am attempting to serve up my local files to heroku. Everything works fine when my debug=True, but I am now setting debug=False and it pushes fine, but then I get a server 500 error.
heroku logs--tail
2020-07-01T20:49:52.625458+00:00 app[web.1]: [2020-07-01 16:49:52 -0400] [10] [INFO] Worker exiting (pid: 10)
2020-07-01T20:49:52.625694+00:00 app[web.1]: [2020-07-01 16:49:52 -0400] [11] [INFO] Worker exiting (pid: 11)
2020-07-01T20:49:52.826436+00:00 app[web.1]: [2020-07-01 20:49:52 +0000] [4] [INFO] Shutting down: Master
2020-07-01T20:49:52.913999+00:00 heroku[web.1]: Process exited with status 0
2020-07-01T21:48:52.452437+00:00 heroku[web.1]: Unidling
2020-07-01T21:48:52.468183+00:00 heroku[web.1]: State changed from down to starting
2020-07-01T21:49:02.609064+00:00 heroku[web.1]: Starting process with command `gunicorn dating_project.wsgi --log-file -`
2020-07-01T21:49:04.647623+00:00 app[web.1]: [2020-07-01 21:49:04 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-07-01T21:49:04.648440+00:00 app[web.1]: [2020-07-01 21:49:04 +0000] [4] [INFO] Listening at: http://0.0.0.0:41874 (4)
2020-07-01T21:49:04.648596+00:00 app[web.1]: [2020-07-01 21:49:04 +0000] [4] [INFO] Using worker: sync
2020-07-01T21:49:04.654902+00:00 app[web.1]: [2020-07-01 21:49:04 +0000] [10] [INFO] Booting worker with pid: 10
2020-07-01T21:49:04.738652+00:00 heroku[web.1]: State changed from starting to up
2020-07-01T21:49:04.752279+00:00 app[web.1]: [2020-07-01 21:49:04 +0000] [12] [INFO] Booting worker with pid: 12
2020-07-01T21:49:06.636432+00:00 heroku[router]: at=info method=GET path="/" host=cupids-corner.herokuapp.com request_id=37718085-380c-4321-a3b2-2e5aa76f3ef9 fwd="69.171.251.32" dyno=web.1 connect=0ms service=101ms status=500 bytes=234 protocol=https
2020-07-01T21:49:06.636517+00:00 app[web.1]: 10.123.144.18 - - [01/Jul/2020:17:49:06 -0400] "GET / HTTP/1.1" 500 27 "-" "facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)"
2020-07-01T22:24:34.101909+00:00 heroku[web.1]: Idling
2020-07-01T22:24:34.108226+00:00 heroku[web.1]: State changed from up to down
2020-07-01T22:24:35.649357+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-07-01T22:24:35.828680+00:00 app[web.1]: [2020-07-01 22:24:35 +0000] [4] [INFO] Handling signal: term
2020-07-01T22:24:35.833183+00:00 app[web.1]: [2020-07-01 18:24:35 -0400] [10] [INFO] Worker exiting (pid: 10)
2020-07-01T22:24:35.833979+00:00 app[web.1]: [2020-07-01 18:24:35 -0400] [12] [INFO] Worker exiting (pid: 12)
2020-07-01T22:24:36.243924+00:00 app[web.1]: [2020-07-01 22:24:36 +0000] [4] [INFO] Shutting down: Master
2020-07-01T22:24:36.503573+00:00 heroku[web.1]: Process exited with status 0
2020-07-01T22:48:24.586757+00:00 heroku[web.1]: Unidling
2020-07-01T22:48:24.598580+00:00 heroku[web.1]: State changed from down to starting
2020-07-01T22:48:34.387802+00:00 heroku[web.1]: Starting process with command `gunicorn dating_project.wsgi --log-file -`
2020-07-01T22:48:36.956090+00:00 app[web.1]: [2020-07-01 22:48:36 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-07-01T22:48:36.956686+00:00 app[web.1]: [2020-07-01 22:48:36 +0000] [4] [INFO] Listening at: http://0.0.0.0:29707 (4)
2020-07-01T22:48:36.956791+00:00 app[web.1]: [2020-07-01 22:48:36 +0000] [4] [INFO] Using worker: sync
2020-07-01T22:48:36.961548+00:00 app[web.1]: [2020-07-01 22:48:36 +0000] [10] [INFO] Booting worker with pid: 10
2020-07-01T22:48:37.011449+00:00 app[web.1]: [2020-07-01 22:48:37 +0000] [11] [INFO] Booting worker with pid: 11
2020-07-01T22:48:37.572416+00:00 heroku[web.1]: State changed from starting to up
2020-07-01T22:48:38.780576+00:00 app[web.1]: 10.35.222.75 - - [01/Jul/2020:18:48:38 -0400] "GET / HTTP/1.1" 500 27 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15"
2020-07-01T22:48:38.781637+00:00 heroku[router]: at=info method=GET path="/" host=cupids-corner.herokuapp.com request_id=9bfa7641-28d6-4c83-a614-81ca43a8f071 fwd="100.36.43.223" dyno=web.1 connect=1ms service=122ms status=500 bytes=234 protocol=https
2020-07-01T22:51:04.000000+00:00 app[api]: Build started by user rezazandirz#gmail.com
2020-07-01T22:51:47.022572+00:00 app[api]: Deploy b014ce08 by user rezazandirz#gmail.com
2020-07-01T22:51:47.022572+00:00 app[api]: Release v25 created by user rezazandirz#gmail.com
2020-07-01T22:51:47.210267+00:00 heroku[web.1]: Restarting
2020-07-01T22:51:47.224325+00:00 heroku[web.1]: State changed from up to starting
2020-07-01T22:51:48.352163+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-07-01T22:51:48.398775+00:00 app[web.1]: [2020-07-01 22:51:48 +0000] [4] [INFO] Handling signal: term
2020-07-01T22:51:48.398787+00:00 app[web.1]: [2020-07-01 18:51:48 -0400] [11] [INFO] Worker exiting (pid: 11)
2020-07-01T22:51:48.398820+00:00 app[web.1]: [2020-07-01 18:51:48 -0400] [10] [INFO] Worker exiting (pid: 10)
2020-07-01T22:51:48.598966+00:00 app[web.1]: [2020-07-01 22:51:48 +0000] [4] [INFO] Shutting down: Master
2020-07-01T22:51:48.689979+00:00 heroku[web.1]: Process exited with status 0
2020-07-01T22:51:56.987648+00:00 heroku[web.1]: Starting process with command `gunicorn dating_project.wsgi --log-file -`
2020-07-01T22:51:58.976646+00:00 app[web.1]: [2020-07-01 22:51:58 +0000] [4] [INFO] Starting gunicorn 20.0.4
2020-07-01T22:51:58.977154+00:00 app[web.1]: [2020-07-01 22:51:58 +0000] [4] [INFO] Listening at: http://0.0.0.0:11871 (4)
2020-07-01T22:51:58.977256+00:00 app[web.1]: [2020-07-01 22:51:58 +0000] [4] [INFO] Using worker: sync
2020-07-01T22:51:58.981061+00:00 app[web.1]: [2020-07-01 22:51:58 +0000] [10] [INFO] Booting worker with pid: 10
2020-07-01T22:51:59.000000+00:00 app[api]: Build succeeded
2020-07-01T22:51:59.063321+00:00 app[web.1]: [2020-07-01 22:51:59 +0000] [12] [INFO] Booting worker with pid: 12
2020-07-01T22:51:59.114928+00:00 heroku[web.1]: State changed from starting to up
2020-07-01T22:52:04.945223+00:00 app[web.1]: Internal Server Error: /
2020-07-01T22:52:04.945232+00:00 app[web.1]: Traceback (most recent call last):
2020-07-01T22:52:04.945233+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/core/handlers/exception.py", line 34, in inner
2020-07-01T22:52:04.945234+00:00 app[web.1]: response = get_response(request)
2020-07-01T22:52:04.945234+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-07-01T22:52:04.945236+00:00 app[web.1]: response = self.process_exception_by_middleware(e, request)
2020-07-01T22:52:04.945236+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-07-01T22:52:04.945237+00:00 app[web.1]: response = wrapped_callback(request, *callback_args, **callback_kwargs)
2020-07-01T22:52:04.945237+00:00 app[web.1]: File "/app/dating_app/views.py", line 34, in home
2020-07-01T22:52:04.945237+00:00 app[web.1]: return render(request, 'dating_app/home.html',context)
2020-07-01T22:52:04.945238+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/shortcuts.py", line 36, in render
2020-07-01T22:52:04.945238+00:00 app[web.1]: content = loader.render_to_string(template_name, context, request, using=using)
2020-07-01T22:52:04.945239+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-07-01T22:52:04.945239+00:00 app[web.1]: return template.render(context, request)
2020-07-01T22:52:04.945240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py", line 61, in render
2020-07-01T22:52:04.945240+00:00 app[web.1]: return self.template.render(context)
2020-07-01T22:52:04.945240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 171, in render
2020-07-01T22:52:04.945241+00:00 app[web.1]: return self._render(context)
2020-07-01T22:52:04.945241+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
2020-07-01T22:52:04.945241+00:00 app[web.1]: return self.nodelist.render(context)
2020-07-01T22:52:04.945242+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 937, in render
2020-07-01T22:52:04.945242+00:00 app[web.1]: bit = node.render_annotated(context)
2020-07-01T22:52:04.945242+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
2020-07-01T22:52:04.945243+00:00 app[web.1]: return self.render(context)
2020-07-01T22:52:04.945243+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/loader_tags.py", line 150, in render
2020-07-01T22:52:04.945244+00:00 app[web.1]: return compiled_parent._render(context)
2020-07-01T22:52:04.945244+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 163, in _render
2020-07-01T22:52:04.945244+00:00 app[web.1]: return self.nodelist.render(context)
2020-07-01T22:52:04.945245+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 937, in render
2020-07-01T22:52:04.945245+00:00 app[web.1]: bit = node.render_annotated(context)
2020-07-01T22:52:04.945246+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/template/base.py", line 904, in render_annotated
2020-07-01T22:52:04.945246+00:00 app[web.1]: return self.render(context)
2020-07-01T22:52:04.945246+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 106, in render
2020-07-01T22:52:04.945267+00:00 app[web.1]: url = self.url(context)
2020-07-01T22:52:04.945268+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 103, in url
2020-07-01T22:52:04.945268+00:00 app[web.1]: return self.handle_simple(path)
2020-07-01T22:52:04.945269+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/templatetags/static.py", line 118, in handle_simple
2020-07-01T22:52:04.945270+00:00 app[web.1]: return staticfiles_storage.url(path)
2020-07-01T22:52:04.945270+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 153, in url
2020-07-01T22:52:04.945270+00:00 app[web.1]: return self._url(self.stored_name, name, force)
2020-07-01T22:52:04.945271+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 132, in _url
2020-07-01T22:52:04.945271+00:00 app[web.1]: hashed_name = hashed_name_func(*args)
2020-07-01T22:52:04.945271+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django/contrib/staticfiles/storage.py", line 420, in stored_name
2020-07-01T22:52:04.945272+00:00 app[web.1]: raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
2020-07-01T22:52:04.945277+00:00 app[web.1]: ValueError: Missing staticfiles manifest entry for 'css/notification.css'
2020-07-01T22:52:04.946264+00:00 app[web.1]: 10.99.209.116 - - [01/Jul/2020:18:52:04 -0400] "GET / HTTP/1.1" 500 27 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.1 Safari/605.1.15"
2020-07-01T22:52:04.946758+00:00 heroku[router]: at=info method=GET path="/" host=cupids-corner.herokuapp.com request_id=e5bb7e35-cd57-4b5b-a0cd-9940627ea7f2 fwd="100.36.43.223" dyno=web.1 connect=6ms service=128ms status=500 bytes=234 protocol=https
settings.py
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = ['cupids-corner.herokuapp.com']
LOGIN_URL = '/login/'
#For Custom Model
AUTH_USER_MODEL = 'dating_app.Profile'
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
#Third party apps
'bootstrap4',
#My apps
'dating_app',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'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 = 'dating_project.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 = 'dating_project.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# 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 = 'US/Eastern'
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/'
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, 'staticfiles')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'dating_app/media')
#Settings for django-bootstrap3
BOOTSTRAP4 = {
'include_jquery' : True,
}
project_root/urls.py
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('dating_app.urls', namespace= 'dating_app')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
project dir tree I have a copy of static in my root folder, and in my app folder
.
├── 11_env
│   ├── bin
│   ├── lib
│   └── pyvenv.cfg
├── Procfile
├── dating_app
│   ├── __init__.py
│   ├── __pycache__
│   ├── admin.py
│   ├── apps.py
│   ├── chat.html
│   ├── forms.py
│   ├── media
│   ├── migrations
│   ├── models.py
│   ├── static
│   ├── tag.py
│   ├── templates
│   ├── templatetags
│   ├── tests.py
│   ├── urls.py
│   └── views.py
├── dating_project
│   ├── __init__.py
│   ├── __pycache__
│   ├── asgi.py
│   ├── settings.py
│   ├── staticfiles
│   ├── urls.py
│   └── wsgi.py
├── db.sqlite3
├── manage.py
├── requirements.txt
└── static
├── css
└── images
requirements.txt
In your settings.py change your STATICFILES_STORAGEfrom
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
to
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
I'm still not sure why but this has worked for me in the past!

Heroku crashed: at=error code=H10 desc="App crashed" method=GET path="/"

I'm deploying my Django project on Heroku but I kept getting this Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command error after typing heroku open.
crashed log
2019-02-08T05:11:47.595848+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=**.herokuapp.com request_id=754cd442-2b92-4d35-ab73-f6f3f4b47dd2 fwd="144.214.90.65" dyno= connect= service= status=503 bytes= protocol=https
2019-02-08T05:11:48.592697+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=**.herokuapp.com request_id=1dfcc7fa-e278-42be-b02a-0df04c824b57 fwd="144.214.90.65" dyno= connect= service= status=503 bytes= protocol=https
heroku logs --tail
2019-02-08T04:25:27.848612+00:00 app[api]: Release v1 created by user ***#gmail.com
2019-02-08T05:10:08.937759+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-08T05:21:19.195680+00:00 heroku[web.1]: State changed from crashed to starting
2019-02-08T05:27:16.830898+00:00 heroku[web.1]: Starting process with command `gunicorn gettingstarted.wsgi --log-file -`
2019-02-08T05:27:19.380582+00:00 heroku[web.1]: State changed from starting to crashed
2019-02-08T05:27:19.363391+00:00 heroku[web.1]: Process exited with status 3
2019-02-08T05:27:19.253888+00:00 app[web.1]: [2019-02-08 05:27:19 +0000] [4] [INFO] Starting gunicorn 19.9.0
2019-02-08T05:27:19.254420+00:00 app[web.1]: [2019-02-08 05:27:19 +0000] [4] [INFO] Listening at: http://0.0.0.0:4868 (4)
2019-02-08T05:27:19.254514+00:00 app[web.1]: [2019-02-08 05:27:19 +0000] [4] [INFO] Using worker: sync
2019-02-08T05:27:19.258397+00:00 app[web.1]: [2019-02-08 05:27:19 +0000] [10] [INFO] Booting worker with pid: 10
2019-02-08T05:27:19.262923+00:00 app[web.1]: [2019-02-08 05:27:19 +0000] [10] [ERROR] Exception in worker process
2019-02-08T05:27:19.262927+00:00 app[web.1]: Traceback (most recent call last):
2019-02-08T05:27:19.262929+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2019-02-08T05:27:19.262931+00:00 app[web.1]: worker.init_process()
2019-02-08T05:27:19.262932+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 129, in init_process
2019-02-08T05:27:19.262934+00:00 app[web.1]: self.load_wsgi()
2019-02-08T05:27:19.262936+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
2019-02-08T05:27:19.262937+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2019-02-08T05:27:19.262939+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
2019-02-08T05:27:19.262941+00:00 app[web.1]: self.callable = self.load()
2019-02-08T05:27:19.262942+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
2019-02-08T05:27:19.262944+00:00 app[web.1]: return self.load_wsgiapp()
2019-02-08T05:27:19.262946+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
2019-02-08T05:27:19.262947+00:00 app[web.1]: return util.import_app(self.app_uri)
2019-02-08T05:27:19.262949+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/gunicorn/util.py", line 350, in import_app
2019-02-08T05:27:19.262950+00:00 app[web.1]: __import__(module)
2019-02-08T05:27:19.262952+00:00 app[web.1]: ModuleNotFoundError: No module named 'gettingstarted'
2019-02-08T05:27:19.263083+00:00 app[web.1]: [2019-02-08 05:27:19 +0000] [10] [INFO] Worker exiting (pid: 10)
2019-02-08T05:27:19.287592+00:00 app[web.1]: [2019-02-08 05:27:19 +0000] [4] [INFO] Shutting down: Master
2019-02-08T05:27:19.287748+00:00 app[web.1]: [2019-02-08 05:27:19 +0000] [4] [INFO] Reason: Worker failed to boot.
My Procfile
web: gunicorn gettingstarted.wsgi --log-file -
settings.py
"""
***
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
ALLOWED_HOSTS = [
'**', # subdoamin wildcard
'localhost',
'127.0.0.1',
'144.214.90.65'
]
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# 'product.apps.ProductConfig',
'product',
]
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',
]
***
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
# os.path.join(BASE_DIR, 'templates'),],
'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',
],
},
},
]
WSGI_APPLICATION = '***.wsgi.application'
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/2.1/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/2.1/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'CET' # UTC + 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
# The URL to use when referring to static files (where they will be served from)
STATIC_URL = '/static/'
# The absolute path to the directory where collectstatic will collect static files for deployment.
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
# check new places here so I
CORS_REPLACE_HTTPS_REFERER = False
HOST_SCHEME = "http://"
SECURE_PROXY_SSL_HEADER = None
SECURE_SSL_REDIRECT = True
SESSION_COOKIE_SECURE = True
CSRF_COOKIE_SECURE = True
SECURE_HSTS_PRELOAD = True
SECURE_HSTS_SECONDS = 60
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
SECURE_FRAME_DENY = False
SECURE_CONTENT_TYPE_NOSNIFF = True
SECURE_BROWSER_XSS_FILTER = True
2019-02-08T05:27:19.262952+00:00 app[web.1]: ModuleNotFoundError: No module named 'gettingstarted'
You've forgotten to add, commit and push gettingstarted directory. It's required by your Procfile.

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)