Configuring Django Apps for Heroku
Last updated March 21, 2022
The basics
First, and most importantly, Heroku web applications require a Procfile
.
This file is used to explicitly declare your application’s process types and entry points. It is located in the root of your repository.
Procfile
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.
Installing gunicorn
$ pip install gunicorn
Be sure to add gunicorn
to your requirements.txt
file as well.
settings.py
changes
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.
We recommend you configure Django manually for now.