Python in Plain English

New Python content every day. Follow to join our 3.5M+ monthly readers.

Follow publication

Deploying a Django Application to Heroku

Photo by Clément H on Unsplash

You’re just a developer who writes code for a small project and hides it from the public. Instead of letting the world to know about what you are working on. If you answered yes to this, you are missing out something big. Not just one thing, but a lot. You’re missing stuff such as job offers, the next big startup. When you look at Facebook, if Mark chose not to deploy his first version of Facebook, today he wouldn’t be called a billionaire. Well, this post is not about becoming a billionaire but how to deploy a Django app on Heroku.

A friend of mine on LinkedIn approached me and asked how he can deploy a Django app. The best cloud platform you can deploy apps for learning purposes. So when he said that I knew he wanted a free tier and something easy to do. Well, Heroku does just that. You can host your apps on Heroku for free when you select hobby package.

I assume you already have a Django application running on your local server. You want some potential employers to see it live, follow along and get the help you need. Deploying an app on Heroku is not difficult at all, it’s pretty easy and you will agree with me soon.

In the root directory of your app create a file name Procfile with no file extension and add this line in the file

web: gunicorn yourName.wsgi — log-file -

All Heroku apps include a Procfile that specifies the commands that are executed by the app on startup, this is the place where you can write some instruction for your such as your apps webserver in our case we are using gunicorn

What next? You are almost done, now go to Heroku and create an account go for a hobby account it’s free with some cool add-ons the dashboard is easy to understand and though you can create an app from there we will use Heroku CLI to create the apps and push it.

Let’s create and push the app to the cloud now before that install Heroku CLI on your machine all instructions are in the link. Run the following commands in the terminal.

git add .
git commit -m "Procfile added"
heroku login #Login with your heroku acc credentials
heroku create your_app_name
git push heroku master

That is it! this should publish the app on Heroku and access it at https://your-app-name.herokuapp.com now you can pick it up from here and change the domain name to your custom name.

So Heroku is a nice cloud infrastructure where you can host your apps and the whole process is easy and I am sure you have agreed with me. In the next article, we will look at how to add persisting static files such as images on Heroku using Cloudinary.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in Python in Plain English

New Python content every day. Follow to join our 3.5M+ monthly readers.

Written by Mathews Musukuma

I am a passionate software engineer. My skill set is Python/Django, JavaScript, and Ionic Framework.

Responses (1)

Write a response

Hey thank you very much for the article, now one thing giving me a blocker is using the CIs with Django

--