django_evolution.compat.picklers

Picklers for working with serialized data.

Classes

DjangoCompatUnpickler(file, *[, ...])

Unpickler compatible with changes to Django class/module paths.

SortedDict(*args, **kwargs)

Compatibility for unpickling a SortedDict.

class django_evolution.compat.picklers.SortedDict(*args, **kwargs)

Bases: dict

Compatibility for unpickling a SortedDict.

Old signatures may use an old Django SortedDict structure, which does not exist in modern versions. This changes any construction of this data structure into a collections.OrderedDict.

static __new__(cls, *args, **kwargs)

Construct an instance of the class.

Parameters:
  • *args (tuple) – Positional arguments to pass to the constructor.

  • **kwargs (dict) – Keyword arguments to pass to the constructor.

Returns:

The new instance.

Return type:

collections.OrderedDict

class django_evolution.compat.picklers.DjangoCompatUnpickler(file, *, fix_imports=True, encoding='ASCII', errors='strict')

Bases: _Unpickler

Unpickler compatible with changes to Django class/module paths.

This provides compatibility across Django versions for various field types, updating referenced module paths for fields to a standard location so that the fields can be located on all Django versions.

find_class(module, name)

Return the class for a given module and class name.

If looking up a class from django.db.models.fields, the class will instead be looked up from django.db.models, fixing lookups on some Django versions.

Parameters:
  • module (unicode) – The module path.

  • name (unicode) – The class name.

Returns:

The resulting class.

Return type:

type

Raises:

AttributeError – The class could not be found in the module.