- Register on Heroku if you are not registered (https://signup.heroku.com/)
- Install Heroku CLI (https://devcenter.heroku.com/articles/heroku-cli)
- Login to Heroku terminal by
heroku login
- Create heroku app by
heroku create
orheroku create <app_name>
for custom name of the application - Run
heroku git:remote -a <app_name>
- Open
settings.py
file and modifyALLOWED_HOSTS
by adding<app_name.herokuapp.com>
- Commit changes by
git commit -m <commit_message>
- Create PostgreSQL database on Heroku by
heroku addons:create heroku-postgresql:hobby-dev
- Go to
https://dashboard.heroku.com/apps/<app_name>/settings
and click on theReveal Config Vars
and copy theDATABASE URL
. It has the following structure:postgres://<DB_USER>:<DB_PASSWORD>@<DB_HOST>:<DB_PORT>/<DB_NAME>
- Set these variables as Heroku environment variables below
DATABASE_URL
with the keysDB_USER
,DB_PASSWORD
,DB_HOST
,DB_PORT
,DB_NAME
and the values retrieved from theDATABASE_URL
- Add the
SECRET_KEY
environment variable and set it to some value - Add the
DISABLE_COLLECTSTATIC
environment variable and set it to 1 - Add the
HEROKU
environment variable and set it to 1 - if you are on a main branch then run
git push heroku main
, otherwise rungit push heroku <branch_name>:main