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 errorlensimport 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 middlewarePrivacy
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.
Keep reading
Python error tracking with tracebacks you can actually debug
Track Python exceptions with full tracebacks, local variables and request context. One line to set up for Django, Flask, FastAPI and Celery. Open source.
Celery task monitoring that connects jobs to the request that queued them
Monitor Celery tasks: failures with tracebacks, task durations, traces that follow a job from the web request that queued it, and alerts for missed beat jobs.
Open-source APM that links slow requests to their errors and logs
Open-source application performance monitoring: p50/p95 latency, throughput, failure rate and distributed traces linked to errors and logs. Self-host free.
Cron job monitoring that notices when a job doesn't run
Get alerted when a cron job or scheduled task fails, runs too long or doesn't run at all. One HTTP call or one decorator. Open source and self-hostable.
Start tracking errors in minutes
Free hosted plan with 5,000 errors a month, or self-host with no limits. No credit card.