Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Django
  • Views
  • Model
  • Template
  • Forms
  • Jinja
  • Python SQLite
  • Flask
  • Json
  • Postman
  • Interview Ques
  • MongoDB
  • Python MongoDB
  • Python Database
  • ReactJS
  • Vue.js
Open In App
Next Article:
Deploying a Django App to Heroku Using Github Repository
Next article icon

Deploying a Django App to Heroku Using Github Repository

Last Updated : 11 May, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

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 :

  • 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.

Next Article
Deploying a Django App to Heroku Using Github Repository

S

sricharanvodnala
Improve
Article Tags :
  • Python
  • Python Django
  • Heroku Cloud
  • Django-deployment
Practice Tags :
  • python

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
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences