Class Registry

A registry of Schema classes. This allows for string lookup of schemas, which may be used with class:fields.Nested.


This module is treated as private API. Users should not need to use this module directly.

marshmallow.class_registry.get_class(classname: str, all: bool = False) list[SchemaType] | SchemaType[source]

Retrieve a class from the registry.


marshmallow.exceptions.RegistryError if the class cannot be found or if there are multiple entries for the given class name.

marshmallow.class_registry.register(classname: str, cls: SchemaType) None[source]

Add a class to the registry of serializer classes. When a class is registered, an entry for both its classname and its full, module-qualified path are added to the registry.


class MyClass:

register("MyClass", MyClass)
# Registry:
# {
#   'MyClass': [],
#   '': [],
# }