Installing Airbrake in a Django app

python flag

Features

Step 1: Install the latest version of pybrake

Airbrake for Django uses our official Python notifier pybrake. To install run:

pip install -U pybrake

Step 2: Configure the Airbrake Django middleware

First, configure project_id and project_key in settings.py:

AIRBRAKE = dict(
    project_id=123,
    project_key='FIXME',
)

Next, activate the Airbrake middleware:

MIDDLEWARE = [
    ...
    'pybrake.django.AirbrakeMiddleware',
]

Finally, configure the airbrake logging handler:

LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'handlers': {
        'airbrake': {
            'level': 'ERROR',
            'class': 'pybrake.LoggingHandler',
        },
    },
    'loggers': {
        'app': {
            'handlers': ['airbrake'],
            'level': 'ERROR',
            'propagate': True,
        },
    },
}

Now you are ready to start reporting errors to Airbrake from your Django app.

Going further

Please visit our official GitHub repo for details on useful features like: