Skip to content

Django

The logfire.instrument_django() method can be used to instrument the Django web framework with Logfire.

Installation

Install logfire with the django extra:

pip install 'logfire[django]'
uv add 'logfire[django]'
rye add logfire -E django
poetry add 'logfire[django]'

Usage

In the settings.py file, add the following lines:

import logfire

# ...All the other settings...

# Add the following lines at the end of the file
logfire.configure()
logfire.instrument_django()

logfire.instrument_django() uses the OpenTelemetry Django Instrumentation package, which you can find more information about here.

Capturing request and response headers