Jump to >


Backports of functionality from Django 1.11’s django.utils.functional.

Note that this module is not considered API-stable. Changes may be made that remove or alter functionality in the future. Please use at your own risk.

class LazyObject[source]

Bases: object

A wrapper for another class that can be used to delay instantiation of the wrapped class.

By subclassing, you have the opportunity to intercept and alter the instantiation. If you don’t need to do that, use SimpleLazyObject.


x.__init__(…) initializes x; see help(type(x)) for signature

__setattr__(name, value)[source]

x.__setattr__(‘name’, value) <==> x.name = value


x.__delattr__(‘name’) <==> del x.name


helper for pickle


alias of __builtin__.type

class SimpleLazyObject(func)[source]

Bases: django.utils.functional.LazyObject

A lazy object initialized from any function.

Designed for compound objects of unknown type. For builtins or objects of known type, use django.utils.functional.lazy.


Pass in a callable that returns the object to be wrapped.

If copies are made of the resulting SimpleLazyObject, which can happen in various circumstances within Django, then you must ensure that the callable can be safely run more than once and will return the same value.

__repr__() <==> repr(x)[source]

Used to unpickle lazy objects. Just return its argument, which will be the wrapped object.