'Provides pickling support. Normally, this just dispatches to Python\'s
standard handling. However, for models with deferred field loading, we
need to do things manually, as they\'re dynamically created classes and
only module-level classes can be pickled by the default path.'

def __reduce__(self):

    if (not self._deferred):
        return super(Model, self).__reduce__()
    data = self.__dict__
    defers = []
    for field in self._meta.fields:
        if isinstance(self.__class__.__dict__.get(field.attname), DeferredAttribute):
            defers.append(field.attname)
    model = self._meta.proxy_for_model
    return (model_unpickle, (model, defers), data)
