I've successfully deployed Django with Whitenoise on Cloudfoundry except for the compression. If I set on my settings.py
to enable compression:
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
I get a 500 error and nothing on my cf logs
. Please not that I don't have SSH access nor/heroku as this is running on Predix.
My settings.py:
STATIC_URL = "/media/"
STATIC_ROOT = os.path.join(BASE_DIR, "media")
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'itcave/media'),
]
MIDDLEWARE_CLASSES = [
'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.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
wsgi.py:
from whitenoise.django import DjangoWhiteNoise
from django.core.wsgi import get_wsgi_application
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "itcave.settings")
application = get_wsgi_application()
application = DjangoWhiteNoise(application)
Please also note that all my static files are stored within a media
folder at the same level as my settings.py
file.
Adding web: python itcave/manage.py collectstatic --noinput
on a line before my run command in Procfile
didn't work. ALLOWED_HOSTS
is correct because when DEBUG = True
everything runs fine.