Django error tracking

Django error tracking without the 500-error email flood

Django can email ADMINS a traceback for every 500 — one email per occurrence, no grouping, no way to mark it fixed. ErrorLens groups those exceptions into issues, adds the request, user and SQL queries, and alerts you once.

Add it to settings.py

Install the package and initialize it in settings.py. The Django integration turns on by itself — no middleware or INSTALLED_APPS entry needed.

pip install errorlens
settings.py
import errorlens

errorlens.init(
    dsn="https://<key>@errorlens.io/<project-id>",
    release="[email protected]",
    traces_sample_rate=0.2,
)

What you get for every Django error

  • The full traceback with source context and local variables for your own frames
  • The request: method, URL, route, headers and query string (cookies and bodies only if you opt in)
  • The transaction named after the URL pattern, e.g. /orders/<int:pk>/, not the raw path
  • Every SQL query run by the request as a span, so slow views and N+1 queries stand out
  • Users and tags you set during the request, kept separate between concurrent requests
  • Both WSGI and ASGI deployments, including async views

Attach the logged-in user

Add the user once per request, for example in a small middleware, and every error shows who was affected:

def errorlens_user(get_response):
    def middleware(request):
        if request.user.is_authenticated:
            errorlens.set_user({"id": request.user.pk})
        return get_response(request)
    return middleware

Privacy

Passwords, tokens, API keys, cookies and card numbers are removed in your app and again on the server before anything is stored — see data scrubbing.

Frequently asked questions

Do I still need ADMINS emails?

No. ErrorLens alerts you once per new issue (and again on regressions or spikes), with a link to the grouped issue, so the ADMINS email handler can be removed.

Does it capture errors from management commands and Celery tasks?

Yes. Uncaught exceptions in management commands are reported, and Celery task failures are captured by the Celery integration.

Which Django versions are supported?

Current Django releases on Python 3.9 and newer, under WSGI or ASGI.

Start tracking errors in minutes

Free hosted plan with 5,000 errors a month, or self-host with no limits. No credit card.