Configuring Django Apps for Heroku
Last updated 02 August 2018
First, and most importantly, Heroku web applications require a
This file is used to explicitly declare your application’s process types and entry points. It is located in the root of your repository.
web: gunicorn myproject.wsgi
This Procfile requires Gunicorn, the production web server that we recommend for Django applications. For more information, see Deploying Python Applications with Gunicorn.
$ pipenv install gunicorn ...
On Heroku, sensitive credentials are stored in the environment as config vars. This includes database connection information (named
DATABASE_URL), which is traditionally hardcoded in Django applications.
The django-heroku package automatically configures your Django application to work on Heroku. It is compatible with Django 2.0 applications.
It provides many niceties, including the reading of
DATABASE_URL, logging configuration, a Heroku CI–compatible
TestRunner, and automatically configures ‘staticfiles’ to “just work”.
$ pipenv install django-heroku ...
Add the following
import statement to the top of
Then add the following to the bottom of
# Activate Django-Heroku. django_heroku.settings(locals())
Deploy, and you should be good to go!