Deploying Python and Django Apps on Heroku
Last updated February 22, 2023
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. See our guide on Django and Static Assets.
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.