These docs are a work-in-progress and are currently undergoing a major rewrite!

Heroku

We strongly suggest you just use Heroku to deploy your app.

The standard configuration will only cost $7/month (for a "hobby" dyno, and free database tiers). This is enough to start building on! Upgrading Postgres will be the most likely next step, especially because it will get you "rolling backups" ($50/month).

The Forge Quickstart includes forge-heroku and will set up the heroku-forge-buildpack for you.

Procfile

By default, you won't find a Procfile in your repo. Our buildpack will create one during the Heroku build process, which looks like this:

web: forge serve
release: forge pre-deploy

If you need to customize the Procfile, simply add one to the root of your repo!

Running commands on production

There will be times when you need to run commands remotely on your production app and production database.

If you need to run a specific manage.py command, you can do it directly like this:

heroku run forge django createsuperuser

But if you're not sure of the exact command, it's best to just run bash and use the shell from there:

heroku run bash

Otherwise you'll spend a lot of time waiting for the temporary dynos to start/stop, just to tell you there was a typo or print out some help text for your next attempt.

You can also jump into a Django/Python shell directly with:

forge shell --heroku

Media and uploads

One trick with deploying to Heroku is that you can't just save uploaded or generated files to the server (ex. when a user uploads an avatar, or you generate and save a PDF). If you do, you'll notice that they disappear! The filesystem on Heroku is ephemeral, so you need to use something like AWS S3 for long-term file storage.

Depending on your app, you may not need to store files like this at all. Because it isn't always needed, Forge doesn't come with a built-in solution for file storage.

If you need to store uploaded files (typically because you want to use models.FileField), then we recommend installing up django-storages. If you're using AWS for anything else, than AWS S3 may be an easy and commonly-used choice for the backend.

Monitoring

Once your site is up, there a few things to consider:

Error monitoring

Sentry is our go-to. You can likely use it for free and set it up yourself, but Forge Pro includes a more complete Sentry integration.

Performance monitoring

If you use Professional dynos (i.e. standard-1x) can set Threshold Alerts on Heroku. These can alert on slow response times and failed requests.

You can also use Sentry's performance monitoring which ties directly into your error monitoring.

Logging

You can view your logs with the Heroku CLI:

heroku logs --tail

By default, these aren't persisted anywhere. If you want to store logs, you'll need to hook up a one of the Heroku add-ons or set up your own log drain.

Backups

The easiest thing to do regarding database backups is to use at least the standard-0 tier of Heroku Postgres ($50/mo). This gives you the ability to "roll back" to a previous state of your database in the last X days, as well as manually and automatically create standalone backups.