How to serve django static files on heroku with gunicorn
While deploying your app first change DEBUG=FALSE
in your setting file.
Following link can be useful.
https://devcenter.heroku.com/articles/django#deploy-to-heroku
To serve static files I highly recommend you to use whitenoise http://whitenoise.evans.io/en/stable/django.html
STATIC_ROOT = os.path.join(PROJECT_PATH, 'staticfiles')STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'MIDDLEWARE_CLASSES = [ # 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', # ...]
No need to run collectstatic
as heroku will do that for you. What that does is puts all the files into the STATIC_ROOT
for you (all compressed and with a hashed file name for long expires).