For more information on concepts covered in this lesson, you can check out:
- Django-Heroku Library | PyPI
- Django-Heroku Repository | GitHub
- PostgreSQL Database Driver | PyPI
- Simplifying Django deployments on Heroku | ehmatthes.com
Here are the command-line snippets used in this lesson:
$ source venv/bin/activate
$ python -m pip install django-heroku
$ python -m pip freeze > requirements.txt
$ cat requirements.txt
$ vim portfolio/settings.py
$ python -c 'import secrets; print(secrets.token_urlsafe())'
$ heroku config:set SECRET_KEY='<your-secret>'
$ heroku config
$ heroku config:unset DISABLE_COLLECTSTATIC
$ git status
$ git commit -am "Install and use django-heroku"
$ git push heroku
$ heroku open
asgiref==3.4.1
dj-database-url==0.5.0
Django==3.2.7
django-heroku==0.3.1
psycopg2==2.9.2
pytz==2021.3
sqlparse==0.4.2
whitenoise==5.3.0
# ...
# Remove or comment out the hardcoded secret key:
# SECRET_KEY = 'django-insecure-3!1cb-qaq$f71ex!$t#ws(+^w$fx%pifq13dc!qow2ui!4^$^g'
# ...
# Let django-heroku set the allowed hosts:
ALLOWED_HOSTS = []
# ...
# Add this at the bottom of your settings file:
import django_heroku
django_heroku.settings(locals())