---
title: Django integration guide
description: Set up Django error tracking, performance monitoring, and observability with Honeybadger in 5 minutes.
url: https://docs.honeybadger.io/lib/python/integrations/django/
---

**Typical installation time:** 5 minutes

Hi there! You’ve found Honeybadger’s guide to **Django error tracking and performance monitoring**. Once installed, Honeybadger will automatically report errors and performance insights from your Django application.

## Installing the package

Install the `honeybadger` Python package with pip (or add it to your `requirements.txt`):

```bash
pip install honeybadger
```

In your Django application, add the Honeybadger Django middleware to *the top* of your `MIDDLEWARE` config variable in `settings.py`:

```python
MIDDLEWARE = [
    'honeybadger.contrib.DjangoHoneybadgerMiddleware',
    # ... your other middleware
]
```

It’s important that the Honeybadger middleware is at the top, so that it wraps the entire request process, including all other middleware.

Add a new `HONEYBADGER` config variable to your `settings.py`:

```python
HONEYBADGER = {
    'API_KEY': 'PROJECT_API_KEY',
    'INSIGHTS_ENABLED': True
}
```

Tip

You can also configure Honeybadger with environment variables:

```sh
export HONEYBADGER_API_KEY="PROJECT_API_KEY"
export HONEYBADGER_INSIGHTS_ENABLED=True
```

If you use this method, you can omit the `HONEYBADGER` configuration from `settings.py`.

See the [Configuration reference](https://docs.honeybadger.io/lib/python/reference/configuration/) for additional info.

## Testing your installation

Note

Honeybadger does not report errors in `development` and `test` environments by default. To enable reporting in development environments, temporarily add `'FORCE_REPORT_DATA': True` to your Honeybadger config.

To test that Honeybadger is working, you can create a simple test exception:

```python
from honeybadger import honeybadger


try:
    raise Exception("Honeybadger test exception")
except Exception as e:
    honeybadger.notify(e)
```

If the installation is working correctly, this error should appear in your Honeybadger dashboard.

## How it works

The `DjangoHoneybadgerMiddleware` integrates with Django’s request/response cycle to automatically capture errors and performance data. When an exception occurs, it automatically adds the following information to the error report:

* **URL**: The full URL the request was sent to
* **Component**: The Django app name (if available)
* **Action**: The view function name
* **Params**: GET or POST parameters (filtered for sensitive data)
* **Session**: Session data (filtered for sensitive data)
* **CGI data**: Request headers and environment variables (filtered for sensitive data)
* **Context**: Username and user ID when `request.user` is authenticated

### Performance monitoring

When [Insights is enabled](https://docs.honeybadger.io/lib/python/insights/capturing-logs-and-events/), the middleware automatically tracks:

* **Request performance**: Response times, status codes, and view information
* **Database queries**: Query duration and SQL statements (with configurable filtering)
* **Request correlation**: Generates or captures request IDs for tracing across systems

## Sending logs from your infrastructure

Honeybadger isn’t just for errors and application data! You can use our [syslog](https://docs.honeybadger.io/guides/insights/integrations/systemd/), [Vector](https://docs.honeybadger.io/guides/insights/integrations/log-files/), or [PaaS integrations](https://docs.honeybadger.io/guides/insights/#adding-data-from-other-sources) to send additional data from your infrastructure to [Honeybadger Insights](https://docs.honeybadger.io/guides/insights/), where you can query, visualize, and analyze all of your production data in one place.

---

## Try Honeybadger for FREE

Intelligent logging, error tracking, and Just Enough APM™ in one dev-friendly platform. Find and fix problems before users notice.

[Start free trial](https://app.honeybadger.io/users/sign_up)

[See plans and pricing](https://www.honeybadger.io/plans/)
