Deploying a Django Application to Heroku
3 min read
You're just a developer who writes code for a small project and hides it from the public. Instead of letting the world know about what you are working on. If you answered yes to this, you are missing out on something big.
Not just one thing, but a lot. You're missing stuff such as job offers, and 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 about 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 the hobby package. I assume you already have a Django application running on your local server. If 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 the following configuration to 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 instructions for your such as your app's web server 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.
Pushing Code to Heroku
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 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.
Did you find this article valuable?
Support Mathews Musukuma by becoming a sponsor. Any amount is appreciated!