Step by step guide to deloy Django Applications on Heroku

Introduction

Most of the software development happens on localhost. But this locally hosted software can only be viewed and tested by one developer. In this world of worldwide collaboration and continuous integration, localhost does not suffice. So, we deploy the test or dev version of the software on a cloud so that all the team members can see it and test it.

So in this post, we are going to see how a Django project can be hosted on Heroku to be viewed by the entire world. In our case, we are going to use the GitHub integration method to deploy code to Heroku because it is the easiest.

What is Django?

Django is a web framework built for Python, generally used for rapid development of websites or web apps. Django has a clean and pragmatic design. They say that Django is built for entrepreneurs. Because it takes care of most of the tedious requirements of web development. This lets you focus solely on developing the app/site.

Django is open source and encourages new developers to contribute to it. As a result of this, it has a wide range of plugins and packages available. The official development repository of Django is hosted on GitHub.

What is Heroku?

In my previous post, we talked about BaaS. This post is about Heroku, which is a PaaS (or Platform as a Service). In a PaaS, developers are provided with a cloud-based platform on which they can run their apps or websites for the world to see. Heroku is the most popular free PaaS service. It supports most of the languages and frameworks.

Dependencies and Prerequisites:

(Optional but recommended) Virtualenv – To create a virtual environment to install only those packages that are needed.

pip install virtualenv
virtualenv env
source env/bin/activate

Django – Obvious why we need this.

Gunicorn – ‘Green Unicorn’ is a WSGI HTTP Server for UNIX.

dj-database-url – Package used for configuring DATABASE_URL in django.