Create the App in Heroku using below URL,
Navigate to the Django Project folder where manage.py resides
heroku git:remote -a <app_name>
Create Procfile in PROJECT_HOME dir
pip install gunicorn
pip install django-heroku
Add the following
import statement to the top of
Then add the following to the bottom of
Django does not support serving static files in production. However, the fantastic WhiteNoise project can integrate into your Django application, and was designed with exactly this purpose in mind.
pip install whitenoise
Next, install WhiteNoise into your Django application. This is done in
settings.py’s middleware section (at the top):
MIDDLEWARE_CLASSES = ( # Simplified static file serving. # https://warehouse.python.org/project/whitenoise/ 'whitenoise.middleware.WhiteNoiseMiddleware', )
Finally, if you’d like gzip functionality enabled, also add the following setting to
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
If collectstatic failed during a build, a traceback was provided that will be helpful in diagnosing the problem. If you need additional information about the environment collectstatic was run in, use the
heroku config:set DEBUG_COLLECTSTATIC=1
Sometimes, you may not want Heroku to run collectstatic on your behalf. You can disable the collectstatic build step with the
heroku config:set DISABLE_COLLECTSTATIC=1
git add .
git commit -am "Initial commit"
git push heroku master
Happy Coding !!!