This article was originally published on CodePerfectPlus.com
Heroku offer a free plan, it's great to start learning and for the host demo 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.
- Add a Procfile in the project root;
- Add Gunicorn to virtualenv;
- A runtime.txt to specify the correct Python version in the project root;
- Configure whitenoise to serve static files.
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
Configure the STATIC-related parameters on settings.py:
Add whienoise to settings.py then in the last of MIDDLEWARE List.
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.
- Deploy Your First Django App With Heroku
- Single-layer Neural Networks in Machine Learning (Perceptrons)
- 5 Tips for Computer Programming Beginners
- What Is Git and GitHub?
- What is Simple Linear Regression?
- Introduction to Machine Learning and it's Type.
- Difference Between Machine Learning and Artificial Intelligence