Heroku is a cloud platform as a service supporting several programming languages. They support several programming languages like Python, Javascript, Java, Php, Go, Scala and Ruby. Heroku offer a free plan, it's great to start learning and for the host demo application.
July 3, 2020 Deepak Raj
Heroku is a cloud platform as a service supporting several programming languages. They support several programming languages like Python, Javascript, Java, Php, Go, Scala and Ruby. Heroku offer a free plan, it's great to start learning and for the host demo application.
Create an account on Heroku and then install the Heroku CLI tool from here. It's Command line tool to deploy and manage your Django application.
$ heroku login
heroku: Press any key to open up the browser to login or q to exit:
In this tutorial, I will deploy my existing project of GitHub API. It's GitHub API project developed 6 months ago and it's also available on Github and you can clone the repository and try it by yourself.
I will be using Heroku CLI with Git. Your application will be saved in a remote git repository in the Heroku Cloud.
Before starting You Have to add some file to your projects.
Create a file named Procfile in the project root with the following content:
web: gunicorn base.wsgi --log-file -
Note: change base with the name of your Django project.
install Gunicorn in VirtualEnv by command:
$ pipenv install gunicorn
$ pipenv install whitenoise
create a filename runtime.txt
python-3.7.6
Configure the STATIC-related parameters on settings.py:
Add whienoise to settings.py then in the last of MIDDLEWARE List.
"whitenoise.middleware.WhiteNoiseMiddleware",
Almost all configurations are completed.
clone the Repository here if you haven't downloaded from upper link.
git clone https://github.com/codePerfectPlus/Deploy-Django-Applications-on-Heroku
cd Deploy-Django-Applications-on-Heroku
$ heroku login
This will be your app name. appname.herokuapp.com. choose clearly the name for the app.
$ heroku create gitapi-project
Creating ⬢ gitapi-project... done
https://gitapi-project.herokuapp.com/https://git.heroku.com/gitapi-project.git
You can simply run heroku create
then Heroku will find the app name by itself.
Now login to Heroku Dashboard and access your recently created app:
Run the following command for the deployment of Django App.
heroku config:set DEBUG_COLLECTSTATIC=1
$ git add .
$ git commit -am "make it better"
$ git push heroku master
Your Application in Live. Enjoy Your Day, Don't forget to comment.
If you like to write article or Improve this article for CodePerfectPlus mail us at codeperfectplus@gmail.com
tags: web development, heroku, django