How to deploy your Django App on Heroku
Hello Devs, Today I'm going to tell you how can you upload your Django project on Heroku in just simple steps..
Hello Devs, Today I'm going to tell you how can you upload your Django project on Heroku in just simple steps..
First of all, install some modules :-
pip install django-heroku
pip install gunicorn
pip install whitenoise
Now add some scripts in your settings.py
django_heroku Configuration
import django_heroku
Whitenoise Configuration
MIDDLEWARE = [
'whitenoise.middleware.WhiteNoiseMiddleware',
]
#This above is very imp for the condition when debug=True, so please paste this file here
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage'
Static and Media Settings
MEDIA_ROOT = os.path.join(BASE_DIR,'media')
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
MEDIA_URL = '/media/'
Now, open cmd and run these commands
Connect your project to your heroku app
heroku git:clone -a project_name
Now Deploy your changes using git
git add .
git commit -am "make it better"
git push heroku master
Now most important add Procfile file without any extension and open your procfile and add this file.
web: gunicorn project_name.wsgi
If you have any problem please contact me or comment.
Thank You