API¶
Getting started¶
You can either use the contextvar
directly by importing it with django_guid.middleware import guid
,
or use the API which also logs changes. If you want to use the contextvar, please see the official Python docs.
To use the API import the functions you’d like to use:
from django_guid import get_guid, set_guid, clear_guid
Example usage¶
import requests
from django.conf import settings
from django_guid import get_guid
requests.get(
url='http://localhost/api',
headers={
'Accept': 'application/json',
settings.DJANGO_GUID['GUID_HEADER_NAME']: get_guid(),
}
)