How To Deploy A Django App On Heroku

Heroku is a platform as a service (PaaS) that enables developers to build, run, and operate applications entirely in the cloud.

_config.yml

Step 1. Create a Procfile in your project root and add the following line.
	web: gunicorn your_project_name.wsgi
Step 2. Go to the command line and install psycopg2, gunicorn, django-heroku and create requirements.txt
	pip install psycopg2
	# And NOW… you’ll be able to install django-heroku 
	pip install gunicorn
	pip install django-heroku
	pip freeze > requirements.txt
Step 3. In your app/settings.py
	import django_heroku 

	# Then all the way at the bottom of the file
	# ... 

	django_heroku.settings(locals()) 
Step 4. push it to heroku
	# login to your heroku
	heroku login

	# create new app if one doesn't yet exist
	heroku create

	# create a new postgres database for your app
	heroku addons:create heroku-postgresql:hobby-dev

	# migrate your database to the heroku app
	heroku run python manage.py migrate

	# before you do this, make sure to add your SECRET_KEY to your env variables in your heroku app settings
	git add .
	git commit -m "deploy to heroku "
	git push heroku master
Written on December 3, 2020