          self.adding = True
  
  
  class Model(six.with_metaclass(ModelBase)):
      _deferred = False
  
      def __init__(self, *args, **kwargs):
          signals.pre_init.send(sender=self.__class__, args=args, kwargs=kwargs)
  
          # Set up the storage for instance state
 
</s> remove     cls = factory(model, attrs)
    return cls.__new__(cls)
 </s> add     return model.__new__(model) </s> remove # This function is needed because data descriptors must be defined on a class
# object, not an instance, to have any effect.

def deferred_class_factory(model, attrs):
    """
    Returns a class object that is a copy of "model" with the specified "attrs"
    being replaced with DeferredAttribute objects. The "pk_value" ties the
    deferred attributes to a particular instance of the model.
    """
    if not attrs:
        return model
    opts = model._meta
    # Never create deferred models based on deferred model
    if model._deferred:
        # Deferred models are proxies for the non-deferred model. We never
        # create chains of defers => proxy_for_model is the non-deferred
        # model.
        model = opts.proxy_for_model
    # The app registry wants a unique name for each model, otherwise the new
    # class won't be created (we get an exception). Therefore, we generate
    # the name using the passed in attrs. It's OK to reuse an existing class
    # object if the attrs are identical.
    name = "%s_Deferred_%s" % (model.__name__, '_'.join(sorted(attrs)))
    name = utils.truncate_name(name, 80, 32)

    try:
        return opts.apps.get_model(model._meta.app_label, name)

    except LookupError:

        class Meta:
            proxy = True
            apps = opts.apps
            app_label = opts.app_label

        overrides = {attr: DeferredAttribute(attr, model) for attr in attrs}
        overrides["Meta"] = Meta
        overrides["__module__"] = model.__module__
        overrides["_deferred"] = True
        return type(str(name), (model,), overrides)


 </s> add  </s> remove         # default implementation of from_db() (could be replaced
        # with super())
        if cls._deferred:
            instance = cls(**zip(field_names, values))
        else:
            instance = cls(*values)
 </s> add         # Default implementation of from_db() (subject to change and could
        # be replaced with super()).
        if len(values) != len(cls._meta.concrete_fields):
            values = list(values)
            values.reverse()
            values = [
                values.pop() if f.attname in field_names else DEFERRED
                for f in cls._meta.concrete_fields
            ]
        new = cls(*values) </s> remove class SpatialProxy(object):
 </s> add class SpatialProxy(DeferredAttribute): </s> remove     def test_deferred_class_factory(self):
        new_class = deferred_class_factory(
            Item,
            ('this_is_some_very_long_attribute_name_so_modelname_truncation_is_triggered',))
        self.assertEqual(
            new_class.__name__,
            'Item_Deferred_this_is_some_very_long_attribute_nac34b1f495507dad6b02e2cb235c875e')

    def test_deferred_class_factory_already_deferred(self):
        deferred_item1 = deferred_class_factory(Item, ('name',))
        deferred_item2 = deferred_class_factory(deferred_item1, ('value',))
        self.assertIs(deferred_item2._meta.proxy_for_model, Item)
        self.assertNotIsInstance(deferred_item2.__dict__.get('name'), DeferredAttribute)
        self.assertIsInstance(deferred_item2.__dict__.get('value'), DeferredAttribute)

    def test_deferred_class_factory_no_attrs(self):
        deferred_cls = deferred_class_factory(Item, ())
        self.assertFalse(deferred_cls._deferred)

    @isolate_apps('defer_regress', kwarg_name='apps')
    def test_deferred_class_factory_apps_reuse(self, apps):
        """
        #25563 - model._meta.apps should be used for caching and
        retrieval of the created proxy class.
        """
        class BaseModel(models.Model):
            field = models.BooleanField()

            class Meta:
                app_label = 'defer_regress'

        deferred_model = deferred_class_factory(BaseModel, ['field'])
        self.assertIs(deferred_model._meta.apps, apps)
        self.assertIs(deferred_class_factory(BaseModel, ['field']), deferred_model)

 </s> add 
          self.adding = True
  
  
  class Model(six.with_metaclass(ModelBase)):

  
      def __init__(self, *args, **kwargs):
          signals.pre_init.send(sender=self.__class__, args=args, kwargs=kwargs)
  
          # Set up the storage for instance state
keep keep keep keep replace keep keep keep keep keep
 Fixed #26207 -- Replaced dynamic classes with non-data descriptors for deferred instance loading. 
django/db/models/base.py