<meta name="clckd" content="6301244fb7ed470eb1cd6b8c31d01ac4" />
Python

Deploy Your Django Application On Heroku

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 the 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

0 Comments
  • No Reviews Yet

Leave a Reply
Please Sign In For Comment.
Login or Signup
Shivam Rohilla
Hi, I'm Shivam Rohilla

Hi! My name is Shivam Rohilla. I am a Full Stack Web Developer, and I'm very passionate and dedicated to my work. With 2 years experience as a professional Full Stack Web Developer.

Follow Me:-

My social media links