django-guid
Middleware that enables single request-response cycle tracing by injecting a unique ID into project logs
What it is and what it does
Django GUID is middleware that injects a unique correlation ID into every request-response cycle and makes it available to your application's logging system. When configured, all log messages generated during a request automatically include that request's ID in brackets, allowing you to group and trace all logs belonging to a single user action or request across multiple functions, services, and middleware layers.
The package works with both ASGI and WSGI servers and stores the correlation ID using ContextVar for thread-safe access. It can accept an incoming correlation ID from a request header (validating it as a UUID if configured), generate a new one if none is provided, and optionally return the ID in the response headers. It also supports integrations with tools like Sentry to synchronize the correlation ID with external tracing systems.
Use it for:
- Debugging production issues by filtering logs for a single user's request ID to see the full execution path
- Correlating logs across microservices when a correlation ID is passed between services in request headers
- Integrating with Sentry or similar error tracking to tag exceptions with the same request ID used in application logs
- Auditing and compliance: tracking which requests touched which data by following the correlation ID through logs
- Performance analysis: identifying slow requests by tracing all operations within a single correlation ID
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Attaches a unique correlation ID to all logs for every Django request, making it easy to trace related log entries across your application.
Yes. This is a stable, actively maintained package with low install friction, no security vulnerabilities, and a clear, focused purpose. It integrates cleanly into Django's middleware stack and requires minimal configuration. Install it if you need to correlate logs across a single request or trace requests through a distributed system.
Install
django-guid on PyPI
pip
pip install django-guiduv
uv add django-guidpoetry
poetry add django-guidInstalling django-guid
Before you install
Low friction install with only two runtime dependencies (django and packaging). The package is actively maintained with a recent release and no known vulnerabilities.
License in practice
Licensed under MIT, a permissive open-source license with minimal restrictions on use, modification, and distribution.
Quickstart
pip install django-guid
# In settings.py:
INSTALLED_APPS = ['django_guid', ...]
MIDDLEWARE = ['django_guid.middleware.guid_middleware', ...]
LOGGING = {
'filters': {'correlation_id': {'()': 'django_guid.log_filters.CorrelationId'}},
'formatters': {'medium': {'format': '%(levelname)s [%(correlation_id)s] %(name)s %(message)s'}},
'handlers': {'console': {'class': 'logging.StreamHandler', 'filters': ['correlation_id']}}
}
Requires Django 3.1.1 or above for ASGI/WSGI support; earlier Django versions require django-guid 2.x with WSGI-only support.
Verify before relying
- Whether the package supports Django versions below 3.1.1 or only 3.1.1 and above as stated in the description
- Performance impact of correlation ID injection on high-throughput applications
- Compatibility with custom logging handlers beyond the standard configuration shown
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4.0,>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — django, packaging |
| Maintenance | actively maintained — 101 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 251,724/month — #8,567 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: django_guid-3.6.1-py3-none-any.whl
Keywords: asgi, async, async support, correlation, correlation-id, django, guid, log id, logging, logging id, middleware, request, request id, request-id, uuid, web, sentry, celery
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
asgi-correlation-idASGI middleware that reads or generates…
permissive · top 5,000 on PyPI
django-cidAssigns unique correlation IDs to incoming HTTP…
permissive · top 15,000 on PyPI
django-request-idAttaches a unique request ID to each Django…
permissive · top 15,000 on PyPI
py-machineidRetrieves the unique machine ID of a host…
permissive · top 5,000 on PyPI
django-log-request-idAttaches a unique request ID to every log…
permissive · top 15,000 on PyPI
drf-api-loggerCaptures and logs Django REST Framework API…
permissive · top 15,000 on PyPI
eliotEliot is a structured logging system that…
permissive · top 15,000 on PyPI
flask-request-id-headerFlask middleware that automatically adds or…
unclear · top 15,000 on PyPI
django-eventstreamAdds Server-Sent Events (SSE) streaming to…
permissive · top 15,000 on PyPI
django-dirtyfieldsTracks which fields on a Django model instance…
permissive · top 15,000 on PyPI