{"id":23068,"library":"django-cid","title":"django-cid","description":"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.","status":"active","version":"3.0","language":"python","source_language":"en","source_url":"https://github.com/Polyconseil/django-cid","tags":["django","correlation-id","tracing","debugging","middleware"],"install":[{"cmd":"pip install django-cid","lang":"bash","label":"pip install"}],"dependencies":[{"reason":"Core framework requirement.","package":"django","optional":false}],"imports":[{"note":"Old name was CIDMiddleware, renamed in v3.0.","wrong":"from cid.middleware import CIDMiddleware","symbol":"CorrelationIdMiddleware","correct":"from cid.middleware import CorrelationIdMiddleware"},{"note":"get_cid moved to top-level module in v3.0.","wrong":"from cid.utils import get_cid","symbol":"get_cid","correct":"from cid import get_cid"}],"quickstart":{"code":"import os\n\n# Add to MIDDLEWARE in settings:\nMIDDLEWARE = [\n    'cid.middleware.CorrelationIdMiddleware',\n    # ...\n]\n\n# Then in views:\nfrom cid import get_cid\n\ndef my_view(request):\n    cid = get_cid(request)\n    return HttpResponse(f'Correlation ID: {cid}')","lang":"python","description":"Basic setup: add middleware and use get_cid() to retrieve the correlation ID."},"warnings":[{"fix":"Replace 'cid.middleware.CIDMiddleware' with 'cid.middleware.CorrelationIdMiddleware' in MIDDLEWARE settings.","message":"Middleware renamed from CIDMiddleware to CorrelationIdMiddleware in v3.0. Old imports will cause ImportError.","severity":"breaking","affected_versions":"<3.0 -> >=3.0"},{"fix":"Change 'from cid.utils import get_cid' to 'from cid import get_cid'.","message":"get_cid function moved from cid.utils to cid top-level. Old import path broken.","severity":"breaking","affected_versions":"<3.0 -> >=3.0"},{"fix":"Pass cid to template context manually: context['cid'] = get_cid(request).","message":"The 'cid' template tag and context processor were removed in v3.0. Use get_cid directly in views or templates via template context.","severity":"deprecated","affected_versions":">=3.0"},{"fix":"Ensure CorrelationIdMiddleware is early in the MIDDLEWARE list (e.g., after CommonMiddleware but before SessionMiddleware).","message":"CorrelationIdMiddleware must be placed before other middlewares that need to access the CID, otherwise get_cid will return None.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'from cid.middleware import CorrelationIdMiddleware' and add 'cid.middleware.CorrelationIdMiddleware' to MIDDLEWARE.","cause":"Middleware renamed to CorrelationIdMiddleware in v3.0.","error":"ImportError: cannot import name 'CIDMiddleware' from 'cid.middleware'"},{"fix":"Use 'from cid import get_cid' instead.","cause":"get_cid moved to cid top-level in v3.0.","error":"ImportError: cannot import name 'get_cid' from 'cid.utils'"},{"fix":"Check that CorrelationIdMiddleware is placed early in MIDDLEWARE and that incoming requests include a valid CID header (e.g., X-Correlation-ID).","cause":"get_cid returns None if the middleware hasn't run yet (wrong middleware order) or if the request lacks a CID header.","error":"AttributeError: 'NoneType' object has no attribute 'split'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}