Sessions

class django_orjson.sessions.OrjsonSerializer[source]

An orjson-based session serializer, replacing Django’s built-in JSONSerializer.

Configure it in your settings:

SESSION_SERIALIZER = "django_orjson.sessions.OrjsonSerializer"

Warning

One-way migration

Migrating from Django’s JSONSerializer to OrjsonSerializer is safe, but the reverse case is not.

Sessions written by JSONSerializer can be read by OrjsonSerializer without issue. But sessions written by OrjsonSerializer can be silently misread by JSONSerializer.

See the note in Signing for more information—Django’s session JSONSerializer is a re-export of the signing one, so they share this limitation.