Registry / web-framework / django-cid

django-cid

JSON →
library3.0pypypiunverified

Adds correlation IDs (CID) to Django requests for tracing and debugging. Currently at version 3.0, requires Python >=3.8. Active development with periodic releases.

pip install django-cid
INSTALL
IMPORT
SIG · DJANGO-CID
D
django-cid
web-frameworkpythonv3.0
Install
3.6s avg
Import
—
Disk
66MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 66.4MB
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 3.6s · import 0.000s · 67MB
66MB installed
● package 66MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

CorrelationIdMiddleware
✓ from cid import CorrelationIdMiddleware
✗ from cid.middleware import CorrelationIdMiddleware

Basic setup: add middleware and use get_cid() to retrieve the correlation ID.

import os # Add to MIDDLEWARE in settings: MIDDLEWARE = [ 'cid.middleware.CorrelationIdMiddleware', # ... ] # Then in views: from cid import get_cid def my_view(request): cid = get_cid(request) return HttpResponse(f'Correlation ID: {cid}')
Debug
Known issues
breakingMiddleware renamed from CIDMiddleware to CorrelationIdMiddleware in v3.0. Old imports will cause ImportError.
fix
Replace 'cid.middleware.CIDMiddleware' with 'cid.middleware.CorrelationIdMiddleware' in MIDDLEWARE settings.
affects: <3.0 -> >=3.0
breakingget_cid function moved from cid.utils to cid top-level. Old import path broken.
fix
Change 'from cid.utils import get_cid' to 'from cid import get_cid'.
affects: <3.0 -> >=3.0
deprecatedThe 'cid' template tag and context processor were removed in v3.0. Use get_cid directly in views or templates via template context.
fix
Pass cid to template context manually: context['cid'] = get_cid(request).
affects: >=3.0
gotchaCorrelationIdMiddleware must be placed before other middlewares that need to access the CID, otherwise get_cid will return None.
fix
Ensure CorrelationIdMiddleware is early in the MIDDLEWARE list (e.g., after CommonMiddleware but before SessionMiddleware).
affects: all
Upgrade
Version history
3.0latest on PyPI · released May 14, 2024
Audit
Dependencies
djangorequiredCore framework requirement.
Agent activity
25 hits · last 30 days
node
22
OpenAI (training)
2
Resources
django-cid — pip install django-cid · libregistry