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
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
How To Deploy a Django Application to Heroku with Git CLI?
Next article icon

How To Deploy a Django Application to Heroku with Git CLI?

Last Updated : 19 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

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 to Heroku using Git CLI.

Deploying Django project using Heroku here are two methods:

  1. Deploying Django project on Heroku using CLI 
  2. Deploying Django project on Heroku using Git CLI

For more details about the First method visit the Deploy Django project on Heroku using CLI

Here we discuss the second method How to deploy a Django project on Heroku using Git CLI, It contains both the Project side Heroku sidestep:

Steps to Deploy Django Application

Follow the below steps to deploy your Django project to Heroku using Git CLI:

Step 1: For Heroku Deployment First we need to install dependencies [library] :

  1. Django-Heroku
  2. gunicorn
  3. whitenoise (It help to connect your project with the server)

Note: Dependencies are always dependent on the project, here mentioned dependency has commonly used in Django apps when you deploy a project on Heroku. For installing dependencies you used the pip command :

pip install <library name> 

Step 2: Create required files.

Heroku basically required two files Procfile and requirements.

  • Procfile : procfile is created at manage.py file directory, procfile does not require any extension :
web: gunicorn <project name>.wsgi --log-file -
  • Requirement: The requirement file will store all the dependencies and their versions regarding the project.

Run following command in cmd:

pip freeze > requirements.txt 

Step 3: Update setting.py file

  • Import django_heroku at the top, it is the configuration of the Django application.
import django_heroku
  • Set DEBUG = False its hides the URL link at the dynamic side.
DEBUG = FALSE
  • Add app URL in allowed hosts
ALLOWED_HOSTS = ["*"] also you pass the url link of the project 
OR
ALLOALLOWED_HOSTS = ["https://elitebatch.herokuapp.com/"]
  • Add whitenoise middleware 
"whitenoise.middleware.WhiteNoiseMiddleware"
  • Add static root (it is required when you use static storage in your project)
  • Add django_heroku setting at the last django_heroku.settings(locals())
django_heroku.settings(locals())

Step 4: Upload your project on GitHub.

Heroku Side Setup: 

  1. First of all, create Heroku Account.
  2. Create an app on Heroku 
  3. Add python build pack
  4. Link your Heroku app with the Github repository - go to your app Heroku desktop and go to the deploy tab select deployment method (Github). After successfully connecting with the deployment method scroll down and search the repository that you want to connect with your app.
  5. After Linking with Github, choose the branch, Heroku gives us two methods either manually or turn on automatic deployment 

Great You have successfully uploaded your project on Heroku using git CLI. Project Live on Heroku and source code are available at https://github.com/vikash98k/elite_batch_article/tree/master/elite_batch Github


Next Article
How To Deploy a Django Application to Heroku with Git CLI?

V

vikash98
Improve
Article Tags :
  • Python
  • Web Technologies
  • Git
  • How To
  • Django-deployment
Practice Tags :
  • python

Similar Reads

    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
    How to Deploy Django Application in AWS EC2?
    In this article, we will study how we can deploy our existing Django web application to Windows Server in AWS EC2. We will also see how to use the public IP of the EC2 instance to access the Django application. For this article, you should know about setting up EC2 in AWS. We will see how to deploy
    3 min read
    Deploying a Django App to Heroku Using Github Repository
    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
    2 min read
    How to Deploy a Django Application in Kubernetes
    In this article, we will study how we can deploy Django web applications to Kubernetes. We will also see how to dockerize and build an image of the Django application using Dockerfile. For this article, you should know about setting up a VM in Azure. We will see how to deploy applications on Linux S
    5 min read
    How to Deploy a Web Application on GCP?
    Google Cloud Platform is one of the cloud service providers that provide various cloud services for a seamless experience. It provides various services like storage, networks, development tools, Analytics tools, infrastructure, and many more. Benefits Of Deploying Web Applications on Google Cloud Pl
    4 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