Overview
This article will describe how to deploy a Django app to Heroku, which includes the necessary setup in Heroku’s dashboard.Prerequisites
- A PlanetScale database — If you haven’t created a database, refer to our PlanetScale quickstart guide to get started.
- A Heroku account.
- A project deployed to Heroku — If you’re just poking around and don’t already have an application to deploy, you can use our Django sample.
Set up the project for Heroku
There are a few requirements for running a Django application in Heroku:-
The
gunicorn
anddjango-heroku
packages as requirements. - A properly setup Procfile.
- Proper Config Var setup in Heroku.
NoteThis article will make use of the django-example GitHub repository that is built for the Connect a Django application to PlanetScale document
Set up the Heroku Config Vars
It’s important to store the connection details for the PlanetScale database in Config Vars in Heroku so they are properly secured. These details can be obtained from the PlanetScale dashboard by clicking the “Connect” button.


MYSQL_ATTR_SSL_CA
, which should be set to /etc/ssl/certs/ca-certificates.crt
NoteHeroku uses Ubuntu by default to run applications deployed to their systems, which is why the
MYSQL_ATTR_SSL_CA
value needs to be different than the default values provided by PlanetScale
Update the requirements
Addgunicorn
and django-heroku
to your requirements.txt
file. This will install the necessary packages when deploying to Heroku. If you are following along using the example provided, here is the updated requirements.txt
file: