There are many platform to deploy your site, so that you can show your activities or work to your friend , relative, colleague and so on. One of the platform to deploy your site is Heroku.Let’s Hang on for a few more minutes to learn how it all works, so you can make the most out of Heroku.
Things You need before you start
Install Python to your local machine.
Install PostgreSQL to your local machine.
Your system or machine should have git(Install Git).
After installing above packages now you are ready to work for deploying your system to Heroku. To work in Heroku you need a Heroku CLI. Let’s Install it.
Install Heroku CLI.
for ubuntu run => snap install heroko-classic
for arch run => pacman -S heroku-cli
for windows run => you can download for this link.
for mac run => brew install heroku/brew/heroku
Now we are ready to use Heroku Command Line Interface (CLI). Now we can use the heroku command from our command shell.
Heroku login command to log in to the Heroku CLI:
run => heroku login from your terminal.
now you are login to heroku by using a command shell
now you can clone your project from git or copy a project to this directory.
remember to delete a .git folder after git clone or copying a project to this directory if file exists.
gunicorn because heroku serve our app by using gunicorn
run=> pip install gunicorn
Add a Procfile in your project directory.
Procfile is a mechanism for declaring what commands are run by your application’s dynos on the Heroku platform.
add => web:gunicorn project_name.wsgi to Procfile
add => python manage.py migrate
Install Django Heroku.
This is a Django library for Heroku applications that ensures a seamless deployment and development experience.
run => pip install django-heroku
now you have to import some library to django setting.py.
import django-heroku to top
Now you have to create a Heroku App.
run => heroku create app_name
app_name can be any but domain name will be prefer to used.
Now last one is to push your code to Heroku.
run => git init
run => git add .
run => git commit
run => heroku git:remote -a app_name
run => git push heroku master
Now your site is deploy to heroku you can see your site in https://app_name.herokuapp.com/ .
Note: Above all code or action do not support for dynamic media file , you have to work by your self for this or i will soon post another blog related to this.
Thank you so much (Learn Grow & Share).