django-cid
Correlation IDs in Django for debugging requests
What it is and what it does
Django Correlation ID is a middleware package that assigns a unique identifier to each incoming HTTP request and propagates it through the Django request/response cycle. This correlation ID can be automatically embedded in all log messages, SQL query comments, rendered templates, and HTTP response headers, making it easy to trace which log entries belong to the same request when debugging multi-request scenarios.
The package solves the problem of log attribution in complex systems where multiple requests are processed concurrently. Instead of manually threading request IDs through your codebase, django-cid handles this automatically via middleware, allowing you to correlate all side effects of a single request without explicit plumbing. It's particularly useful in service-oriented architectures where you need to pass the correlation ID to downstream services.
Use it for:
- Trace all log messages belonging to a single user request across multiple application components and services.
- Debug production issues by filtering logs by correlation ID to isolate the request that caused a problem.
- Include correlation IDs in SQL query comments to link database activity to specific HTTP requests.
- Pass correlation IDs to downstream microservices via HTTP headers to maintain request tracing across service boundaries.
- Render correlation IDs in error pages or response headers for customer support reference.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Assigns unique correlation IDs to incoming HTTP requests and automatically includes them in Django logs, SQL queries, templates, and HTTP response headers to trace related log messages across a request lifecycle.
Yes, if you use Django and need request tracing for debugging. The package is stable, has low install friction, and solves a real problem in multi-request logging scenarios. The dormant maintenance status is acceptable for a mature, feature-complete tool—no active vulnerabilities and it supports current Django and Python versions. Install it if request correlation is important to your logging strategy.
Install
django-cid on PyPI
pip
pip install django-ciduv
uv add django-cidpoetry
poetry add django-cidInstalling django-cid
Before you install
Low install friction with a single runtime dependency on django. Maintenance is dormant—no releases since May 2024, though the repository remains active and the package is marked Production/Stable. Suitable for stable projects that don't require frequent updates.
License in practice
BSD-3-Clause is a permissive open-source license. You may use, modify, and distribute this package freely in commercial and private projects, provided you include the license text and do not hold the authors liable.
Quickstart
pip install django-cid
# In Django settings.py, add to MIDDLEWARE:
MIDDLEWARE = [
'django_cid.middleware.CIDMiddleware',
# ...
]
# Correlation ID is then available in logs and can be accessed via:
from django_cid import get_cid
cid = get_cid()
Requires Django >= 3.1 and Python >= 3.8.
Verify before relying
- Whether the package works with Django versions beyond 4.2 (latest tested version in classifiers).
- Performance impact of automatic SQL query annotation on high-throughput applications.
- Compatibility with async Django views and middleware.
Package facts
| License | BSD-3-Clause (permissive) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — django |
| Maintenance | dormant — 822 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 129,263/month — #11,676 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_cid-3.0-py3-none-any.whl
Keywords: django, logging, correlation, id, debugging
Tags
More Monitoring packages
Wraps any iterable to display a real-time…
copyleft · top 100 on PyPI
opentelemetry-semantic-conventionsProvides generated Python code for…
permissive · top 100 on PyPI
opentelemetry-sdkProvides the reference implementation of the…
permissive · top 100 on PyPI
opentelemetry-apiProvides the abstract API and interfaces for…
permissive · top 100 on PyPI
opentelemetry-exporter-otlp-proto-httpExports OpenTelemetry observability data to an…
permissive · top 1,000 on PyPI
opentelemetry-instrumentationProvides automatic instrumentation commands and…
permissive · top 1,000 on PyPI
django-guidAttaches a unique correlation ID to all logs…
permissive · top 15,000 on PyPI
asgi-correlation-idASGI middleware that reads or generates…
permissive · top 5,000 on PyPI
django-queryinspectDjango middleware that logs and reports SQL…
permissive · top 15,000 on PyPI
django-log-request-idAttaches a unique request ID to every log…
permissive · top 15,000 on PyPI
django-request-loggingA Django middleware that logs HTTP request and…
permissive · top 15,000 on PyPI
Flask-Log-Request-IDExtracts request IDs from incoming HTTP…
permissive · top 15,000 on PyPI
eliotEliot is a structured logging system that…
permissive · top 15,000 on PyPI
django-dirtyfieldsTracks which fields on a Django model instance…
permissive · top 15,000 on PyPI
django-cors-headersAdds Cross-Origin Resource Sharing (CORS)…
permissive · top 1,000 on PyPI
opencensus-ext-loggingEnriches Python log records with OpenCensus…
permissive · top 15,000 on PyPI