- Ensure you have an active and valid Heroku account
- Install the Heroku CLI
- See Getting Started on Heroku with Python | Heroku Dev Center
- Note autocomplete instructions
- Prepare the app:
- Clone the repository using git and change to its directory
- Create the app:
heroku create --team=TEAMNAME
- Allow Heroku to set a random name
- Specify the team (omit if not applicable)
- If you want a specific Heroku PostgreSQL plan, it's easiest to specify
it here (ex.
--addons=heroku-postgresql:standard-0
)
- Manage config variables (this can be done using the Heroku Dashboard too)
- Edit config variables
- Command
heroku config:edit
- Template (Be sure to replace the
xxxxxx
values with appropriate data)DJANGO_DEBUG_ENABLED=False DJANGO_SECRET_KEY=xxxxxx DJANGO_SUPERUSER_EMAIL=xxxxxx DJANGO_SUPERUSER_PASSWORD=xxxxxx DJANGO_SUPERUSER_USERNAME=admin
- Command
- View/verify config variables
heroku config
- Edit config variables
- Deploy:
git push heroku main
- (If you didn't specify
--addons=heroku-postgresql:xxxxxx
, above, the PostgreSQL instance will be created and linked automatically ✨)
- (If you didn't specify
- (optional) Change dyno type.
⚠️ WARNING: the following command will incur a monthly charge
heroku ps:type standard-1x
- Open the new app in your browser:
heroku open
- Add
admin/
to the URL to access the admin interface
- Add
- Import database
⚠️ WARNING: this assumes any existing data can be destroyed
heroku pg:psql < backup.sql
Django database migrations are triggered by bin/release_tasks
, which is
called by the Procfile
(The Procfile | Heroku Dev Center).
Convert it:
pg_restore -f backup.sql backup.dump
If you receive an error like the following, ensure a firewall is not blocking communication on port 5432
psql: error: could not connect to server: could not connect to server:
Connection refused