Deploying a Django App to Heroku Using Github Repository
Last Updated : 11 May, 2022
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
- Django app
- Heroku account
We need to do certain amendments to the Django app to get it ready to be hosted.
Preparing Django app :
- Install gunicorn library using the below command
pip install gunicorn
- Create a file without any extension and name it as Procfile
Fill the Procfile in the following way
web: gunicorn app_name.wsgi --log-file -
Procfile- Create a requirements.txt file and dump all the dependencies in it
You can use the below command to get all the dependencies into requirements.txt
pip freeze > requirements.txt
requirements.txt- Create a runtime.txt and mention the python version you used to develop your Django app
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.
- Log in to your Heroku account
- Click on new -> create new app.

- Select your app name and region and then click on create app

- Select your app and go to the Deploy menu you can see the option to connect your Github to your Heroku app.
Deploy options- Click on connect to GitHub and authorize your GitHub account
- After authorization, it will ask you to enter the repository you want to connect and the branch to deploy.
connect your repository- You can enable automatic deployments to maintain the latest changes with your commits or else you can deploy whenever you want with the latest changes.
deploy- Once you click on Deploy Branch your app gets deployed.
Initialization of deployment Finally, your Django app got deployed.
Finally deployed!!!- Now your app will be available at https://YourAppName.herokuapp.com
- If you have selected automatic deployments all your commits get deployed otherwise you need to deploy your changes.
- The best part is that if any deployment does not work you can roll back to any version you want by simply clicking the rollback option in the "Activity" tab.
Similar Reads
How To Deploy a Django Application to Heroku with Git CLI? Deploying a Django application to Heroku using the Git command-line interface (CLI) is a simple process. Heroku provides a platform-as-a-service (PaaS) that enables you to deploy, manage, and scale your applications easily. This guide will walk you through the steps to deploy your Django application
3 min read
How to deploy Node.js app on Heroku from GitHub ? In this article, we will be looking at how to deploy your Demo Node.js app to Heroku. At the end of this article, we will have a basic Hello World app running on a public domain that can be accessed by anyone. The Node must be installed on your machine. Refer to this article How to install Node on y
3 min read
Deploying Django App on Heroku with Postgres as Backend Django is a high-level Python web framework used to create web applications without any hassle, whereas, PostgreSQL is a powerful, open-source object-relational database. Let us first create a Django application with PostgreSQL in the backend and deploy it in Heroku which is a container-based cloud
5 min read
How to Deploy Django application on Heroku ? Django is an MVT web framework used to build web applications. It is robust, simple, and helps web developers to write clean, efficient, and powerful code. In this article, we will learn how to deploy a Django project on Heroku in simple steps. For this, a Django project should be ready, visit the f
4 min read
Clone and Run a Django Project from Github In this article, we will learn how to download any project from GitHub and deploy it to our local machine. You can clone any code or project from GitHub but for this article, we are cloning our Django project. What is GitHub?GitHub is an online platform where we can share our codes(or projects) onli
2 min read