- Create a
Procfile
in the root folder and typeweb: gunicorn <name of your app>.wsgi
- Create
requirements.txt
in the root folder bypip freeze >requirements.txt
- Create a
runtime.txt
in the app root folder and type the python version your app is using for examplepython-3.6.3
- Setup the static assets by:
-
In your settings.py ``PROJECT_ROOT = os.path.dirname(os.path.abspath(file))
- STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles')
- STATIC_URL = '/static/'
STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, 'static'),) ``
-
Install whitenoise
python3.6 -m pip install whitenoise
-
Add whitenoise to your wsgi.py file. ``import os from django.core.wsgi import get_wsgi_application from whitenoise.django import DjangoWhiteNoise
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bootcamp.settings")
application = get_wsgi_application() application = DjangoWhiteNoise(application) ``
-
Update settings.py
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
-
Deploy:
git add .;git commit -m "Deploy to heroku";git push heroku master;heroku open
-