skillfed

django-cid

Correlation IDs in Django for debugging requests

django-cid v3.0 129.3K downloads/30d#11,676 on PyPI46
Permissive license BSD-3-Clause DORMANT released

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-cid

uv

uv add django-cid

poetry

poetry add django-cid

Installing 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

Development Status :: 5 - Production/StableFramework :: DjangoFramework :: Django :: 3Framework :: Django :: 3.1Framework :: Django :: 3.2Framework :: Django :: 4Framework :: Django :: 4.0Framework :: Django :: 4.1Framework :: Django :: 4.2Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseNatural Language :: EnglishProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9

Tags

django request correlation idrequest tracing loggingdjango request id trackingcorrelation id middlewaretrace requests across logsdjango debugging request flowrequest lifecycle tracking
request-tracingdjango-middlewarelogging-instrumentation

More Monitoring packages

tqdm

Wraps any iterable to display a real-time…

copyleft · top 100 on PyPI

opentelemetry-semantic-conventions

Provides generated Python code for…

permissive · top 100 on PyPI

opentelemetry-sdk

Provides the reference implementation of the…

permissive · top 100 on PyPI

opentelemetry-api

Provides the abstract API and interfaces for…

permissive · top 100 on PyPI

opentelemetry-exporter-otlp-proto-http

Exports OpenTelemetry observability data to an…

permissive · top 1,000 on PyPI

opentelemetry-instrumentation

Provides automatic instrumentation commands and…

permissive · top 1,000 on PyPI

django-guid

Attaches a unique correlation ID to all logs…

permissive · top 15,000 on PyPI

asgi-correlation-id

ASGI middleware that reads or generates…

permissive · top 5,000 on PyPI

django-queryinspect

Django middleware that logs and reports SQL…

permissive · top 15,000 on PyPI

django-log-request-id

Attaches a unique request ID to every log…

permissive · top 15,000 on PyPI

django-request-logging

A Django middleware that logs HTTP request and…

permissive · top 15,000 on PyPI

Flask-Log-Request-ID

Extracts request IDs from incoming HTTP…

permissive · top 15,000 on PyPI

eliot

Eliot is a structured logging system that…

permissive · top 15,000 on PyPI

django-dirtyfields

Tracks which fields on a Django model instance…

permissive · top 15,000 on PyPI

django-cors-headers

Adds Cross-Origin Resource Sharing (CORS)…

permissive · top 1,000 on PyPI

opencensus-ext-logging

Enriches Python log records with OpenCensus…

permissive · top 15,000 on PyPI