skillfed

django-guid

Middleware that enables single request-response cycle tracing by injecting a unique ID into project logs

django-guid v3.6.1 251.7K downloads/30d#8,567 on PyPI484
Permissive license MIT Active released

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

uv

uv add django-guid

poetry

poetry add django-guid

Installing 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

Development Status :: 5 - Production/StableEnvironment :: Web EnvironmentFramework :: DjangoFramework :: Django :: 4.2Framework :: Django :: 5.0Framework :: Django :: 5.1Framework :: Django :: 5.2Framework :: Django :: 6.0Intended Audience :: DevelopersLicense :: OSI Approved :: BSD LicenseLicense :: OSI Approved :: MIT LicenseOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Internet :: WWW/HTTPTopic :: Internet :: WWW/HTTP :: Dynamic ContentTopic :: Internet :: WWW/HTTP :: WSGITopic :: Software DevelopmentTopic :: Software Development :: LibrariesTopic :: Software Development :: Libraries :: Application FrameworksTopic :: Software Development :: Libraries :: Python Modules

Tags

django request tracingcorrelation id loggingrequest id middlewaredjango guid loggingtrace requests across logsdjango request trackingasgi wsgi request id
request-tracinglogging-middlewareasgi-wsgi

More Software Development packages