SlideShare a Scribd company logo
Building a Django
App with Heroku
Get your project up and running in 20 minutes
or less.
What is Heroku?
● Platform-as-a-Service (PaaS)
● Acquired by salesforce.com in 2010
Why Heroku?
●
●
●
●

Focus on developer productivity
100% free plan includes hosting & db
No need to think about servers
Easily scales
Prerequisites
Familiarity with:
● command line
● git
Prerequisites
Install:
● pip
http://www.pip-installer.org
● Postgres
pip install psycopg2
http://initd.org/psycopg/
Prerequisites
Install:
● Virtualenv
pip install virtualenv
Getting Started
1. Sign up for a Heroku account at Heroku.com
2. Install Heroku Toolbelt: https://toolbelt.heroku.com
3. Log in via command line
Create a Django app locally
$
$
$
$
$

mkdir mysite && cd mysite
virtualenv venv --distribute
source venv/bin/activate
pip install django-toolbelt
django-admin.py startproject mysite .
Create a Procfile
Create a Procfile in your root project directory:
# Procfile
web: gunicorn hellodjango.wsgi
Create requirements.txt
$ pip freeze > requirements.txt
Note: If you do this out of order, you’ll need to
manually create requirements.txt
Modify settings.py
import dj_database_url
DATABASES['default'] =

dj_database_url.config()

SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
ALLOWED_HOSTS = ['*']
# Static asset configuration
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
Modify wsgi.py
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
application = Cling(get_wsgi_application())
Store your app in git
First create a .gitignore file; add:

venv
*.pyc
staticfiles
Store your app in git
Initialize a new git repository
$ git init
Add the new files
$ git add .
Commit your files
$ git commit -m "initial commit"
Push your code to Heroku
Create a new app on Heroku
$ heroku create
Deploy your code to Heroku
$ git push heroku master
Start your app

Each Heroku
app comes
with 1 free
dyno.

Start a Heroku dyno
$ heroku ps:scale web=1
Scaling dynos... done, now running web at 1:1X.
Terminology: Dynos are isolated, virtualized Unix containers, that
provide the environment required to run an application.
Visit your app
$ heroku open
Visit your app
Congrats! You’ve set up a live Djangopowered application via Heroku.

More Related Content

ODP
Marek Kuziel - Deploying Django with Buildout
PPTX
A painless self-hosted Git service: Gitea
PPTX
Introduction to Gitea with Drone
PDF
Django Deployer
PDF
Practical Android Course Part I - Introduction, Activities (KNI)
PDF
Introduction to development with Django web framework
PPTX
DevOps for Hackathons: DevOps without the Ops
PDF
Google App Engine Developer - Day1
Marek Kuziel - Deploying Django with Buildout
A painless self-hosted Git service: Gitea
Introduction to Gitea with Drone
Django Deployer
Practical Android Course Part I - Introduction, Activities (KNI)
Introduction to development with Django web framework
DevOps for Hackathons: DevOps without the Ops
Google App Engine Developer - Day1

What's hot (20)

PPTX
Up GitLab Presentation 2015
PDF
Go dla elektronika
PDF
Git work flow
PPTX
Continuously Break The Android
PDF
Introduction to git flow
PPTX
Mobile CICD
PDF
WSO2 Screencast - How to Easily Build a Git-Based CI/CD Pipeline for your API...
PDF
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
PPTX
Understanding GitFlow by Ian Vizarra
PDF
jQuery plugin & testing with Jasmine
PPTX
Git representation
PPTX
React and Web Performance
PDF
Flutter workshop @ bang saen 2020
PPTX
Magento PWA Studio extensibility
PDF
用 Go 語言實戰 Push Notification 服務
PPTX
Project onion with swagger
PDF
Aprende, contribuye, y surfea Cloud Native Java - GuateJUG 2021
PPTX
Live development & tools
PPTX
Modifying Android Apps Without Source Codes
PDF
Flutter Workshop 2021 @ ARU
Up GitLab Presentation 2015
Go dla elektronika
Git work flow
Continuously Break The Android
Introduction to git flow
Mobile CICD
WSO2 Screencast - How to Easily Build a Git-Based CI/CD Pipeline for your API...
Agile NCR 2013- Shekhar Gulati - Open shift platform-for-rapid-and-agile-deve...
Understanding GitFlow by Ian Vizarra
jQuery plugin & testing with Jasmine
Git representation
React and Web Performance
Flutter workshop @ bang saen 2020
Magento PWA Studio extensibility
用 Go 語言實戰 Push Notification 服務
Project onion with swagger
Aprende, contribuye, y surfea Cloud Native Java - GuateJUG 2021
Live development & tools
Modifying Android Apps Without Source Codes
Flutter Workshop 2021 @ ARU
Ad

Similar to Building a Django App with Heroku (20)

PDF
Building a Django App on Heroku
PDF
Heroku pycon
PDF
Batteries not included
PDF
Two scoops of Django - Deployment
PDF
Django for Professionals Production websites with Python Django 4 0 William S...
PDF
Scalable Django Architecture
PDF
Django for mobile applications
PDF
Prototyping in the cloud
PDF
Heroku webcastdeck+20130828
PDF
Django For Beginners Converted William S Vincent
PDF
Lab305 Django Facebook Connect Integration Example
PDF
Django: Beyond Basics
PDF
Quick and Dirty Python Deployments with Heroku
PDF
Future of Development and Deployment using Docker
PPT
Django Hosting
PDF
A practical 10m intro to PHP on Heroku
PDF
Django 프로젝트 - heroku 배포하기
PDF
What the heck went wrong?
ODP
Presentasi jlp
PDF
Running Django on Docker: a workflow and code
Building a Django App on Heroku
Heroku pycon
Batteries not included
Two scoops of Django - Deployment
Django for Professionals Production websites with Python Django 4 0 William S...
Scalable Django Architecture
Django for mobile applications
Prototyping in the cloud
Heroku webcastdeck+20130828
Django For Beginners Converted William S Vincent
Lab305 Django Facebook Connect Integration Example
Django: Beyond Basics
Quick and Dirty Python Deployments with Heroku
Future of Development and Deployment using Docker
Django Hosting
A practical 10m intro to PHP on Heroku
Django 프로젝트 - heroku 배포하기
What the heck went wrong?
Presentasi jlp
Running Django on Docker: a workflow and code
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Empathic Computing: Creating Shared Understanding
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Cloud computing and distributed systems.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
cuic standard and advanced reporting.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Encapsulation theory and applications.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Electronic commerce courselecture one. Pdf
Machine learning based COVID-19 study performance prediction
Empathic Computing: Creating Shared Understanding
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
Digital-Transformation-Roadmap-for-Companies.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Unlocking AI with Model Context Protocol (MCP)
Cloud computing and distributed systems.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Diabetes mellitus diagnosis method based random forest with bat algorithm
Programs and apps: productivity, graphics, security and other tools
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Encapsulation theory and applications.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

Building a Django App with Heroku