Deploying a Django App to Heroku
This article was AI-drafted and has not been reviewed yet. Spotted a mistake? Tell us.
Learn how to deploy a Django app to Heroku, a popular cloud platform for building and deploying web applications.
Introduction to Heroku Deployment
Heroku is a popular cloud platform for building and deploying web applications. In this tutorial, we will explore how to deploy a Django app to Heroku.
Step 1: Create a Heroku Account
Create a Heroku account and install the Heroku CLI:
brew install heroku
Step 2: Initialize a Git Repository
Initialize a Git repository for your Django project:
git init
Step 3: Create a Heroku App
Create a new Heroku app using the Heroku CLI:
heroku create
Step 4: Configure the Django App for Heroku
Configure the Django app to use Heroku's PostgreSQL database:
import os
django.db.backends.postgresql_psycopg2
Step 5: Deploy the App to Heroku
Deploy the app to Heroku using the Heroku CLI:
git add .
git commit -m 'Initial commit'
heroku git:remote -a <app-name>
git push heroku master
Step 6: Run Migrations and Collect Static Files
Run migrations and collect static files on Heroku:
heroku run python manage.py migrate
heroku run python manage.py collectstatic
Ready for more? Optional paid resources that pick up where this lesson leaves off.
Some links on this page are affiliate links: we may earn a commission at no extra cost to you. As an Amazon Associate I earn from qualifying purchases.
Project-based Django courses if you want a structured paid path after the free lessons. Wait for a sale — prices drop often.
Browse on Udemy →Search Amazon for Django books — check the publication year so the examples match current versions.
Search Amazon →