Open In App

Deploying a Django App to Heroku Using Github Repository

Heroku is a free hosting cloud service provider. We can use our free dynos to deploy our applications on the cloud. The only disadvantage is that it loses all the data once the app sleeps and it cannot handle multiple requests at a time when hosted on free dynos.

First of all, to proceed further you need to have these two things ready



  1. Django app
  2. Heroku account

We need to do certain amendments to the Django app to get it ready to be hosted.

Preparing Django app :

pip install gunicorn

Fill the Procfile in the following way



web: gunicorn app_name.wsgi --log-file -

Procfile

You can use the below command to get all the dependencies into requirements.txt

pip freeze > requirements.txt

requirements.txt

python-full version

runtime.txt

Note: you need to create all these files outside the Django app i.e. at the same location of the manage.py  file

Now push your Django app to a Github repository and keep it ready.

We assume that you know how to push your code to the GitHub repository.

Deploying to Heroku:

In the first place, you need to have a Heroku account, create one in case you don’t have one.

Deploy options

connect your repository

deploy

Initialization of deployment

Finally, your Django app got deployed.

Finally deployed!!!

Article Tags :