'Retrieves and caches the value from the datastore on the first lookup.
Returns the cached value.'

def __get__(self, instance, owner):

    from django.db.models.fields import FieldDoesNotExist
    non_deferred_model = instance._meta.proxy_for_model
    opts = non_deferred_model._meta
    assert (instance is not None)
    data = instance.__dict__
    if (data.get(self.field_name, self) is self):
        try:
            f = opts.get_field_by_name(self.field_name)[0]
        except FieldDoesNotExist:
            f = [f for f in opts.fields if (f.attname == self.field_name)][0]
        name = f.name
        val = self._check_parent_chain(instance, name)
        if (val is None):
            val = getattr(non_deferred_model._base_manager.only(name).using(instance._state.db).get(pk=instance.pk), self.field_name)
        data[self.field_name] = val
    return data[self.field_name]
