Skip to content

Instantly share code, notes, and snippets.

@AhmadAyyaz1993
Forked from CleverProgrammer/Procfile
Last active January 18, 2019 18:45
Show Gist options
  • Save AhmadAyyaz1993/3ccb9cb9f1893f6059d6a270440f6915 to your computer and use it in GitHub Desktop.
Save AhmadAyyaz1993/3ccb9cb9f1893f6059d6a270440f6915 to your computer and use it in GitHub Desktop.
How to Host a Django App on Heroku
# add a Profile in the root folder of your project where manage.py exists and add the line below to your Procfile and replace
# project_name with your Project name
web: gunicorn project_name.wsgi
pip install gunicorn
pip install django-heroku
pip freeze > requirements.txt
# 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
#connect with your project
heroku git:remote -a Project-name-on-heroku
# 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 "Ready to heroku this sucker in the face."
git push heroku master
# migrate your database to the heroku app. This needs to be in the end to make the migrations for the db
heroku run python manage.py migrate
#update settings.py file
import django_heroku
# All the way at the bottom of the file
# ...
django_heroku.settings(locals())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment