Deploying Python and Django Apps on Heroku
Last updated June 03, 2020
For a step-by-step introduction to deploying Python apps on Heroku, see Getting Started on Heroku with Python.
Expected files for Python
Heroku automatically identifies your app as a Python app if any of the following files are present in its root directory:
If none of these files is present in your app’s root directory, the Python buildpack will fail to identify your application correctly.
Python deployment flow
When you deploy to Heroku, the dependencies you specify in your
requirements.txt file are automatically installed before app startup.
If you’re using Django, the
collectstatic command also runs automatically during the deployment process. This command can be tricky to configure properly. To make it easier, add the Django-Heroku Python package, which sets up everything for you.
To automatically perform other tasks (such as any required database migrations) before your app is deployed, you can add a release phase command to your app.
Python versions and upgrades
By default, your app continues to use whatever version of Python was used when it was first deployed. You can specify a different Python runtime to use in your app’s
You will be notified in your app’s build output if the app’s Python version is no longer up to date.