          if not hasattr(obj, "_meta"):
              raise base.SerializationError("Non-model object (%s) encountered during serialization" % type(obj))
  
          self.indent(1)
          model = obj._meta.proxy_for_model if obj._deferred else obj.__class__
          attrs = OrderedDict([("model", smart_text(model._meta))])
          if not self.use_natural_primary_keys or not hasattr(obj, 'natural_key'):
              obj_pk = obj._get_pk_val()
              if obj_pk is not None:
                  attrs['pk'] = smart_text(obj_pk)
  
 
</s> remove         model = obj._meta.proxy_for_model if obj._deferred else obj.__class__
        data = OrderedDict([('model', force_text(model._meta))])
 </s> add         data = OrderedDict([('model', force_text(obj._meta))]) </s> remove         if self._deferred:
            non_deferred_model = self._meta.proxy_for_model
        else:
            non_deferred_model = self.__class__
        db_instance_qs = non_deferred_model._default_manager.using(db).filter(pk=self.pk)
 </s> add         db_instance_qs = self.__class__._default_manager.using(db).filter(pk=self.pk) </s> remove         elif self._deferred:
            deferred_fields = self.get_deferred_fields()
 </s> add         elif deferred_fields: </s> remove             # This slightly odd construct is so that we can access any
            # data-descriptor object (DeferredAttribute) without triggering its
            # __get__ method.
            if (field.attname not in kwargs and
                    (isinstance(self.__class__.__dict__.get(field.attname), DeferredAttribute) or
                        field.column is None)):
                # This field will be populated on request.
 </s> add             # Virtual field
            if field.attname not in kwargs and field.column is None:
        attrs = OrderedDict([("model", smart_text(obj._meta))])
          if not hasattr(obj, "_meta"):
              raise base.SerializationError("Non-model object (%s) encountered during serialization" % type(obj))
  
          self.indent(1)
        attrs = OrderedDict([("model", smart_text(obj._meta))])
        attrs = OrderedDict([("model", smart_text(obj._meta))])
          if not self.use_natural_primary_keys or not hasattr(obj, 'natural_key'):
              obj_pk = obj._get_pk_val()
              if obj_pk is not None:
                  attrs['pk'] = smart_text(obj_pk)
  
keep keep keep keep replace replace keep keep keep keep keep
 Fixed #26207 -- Replaced dynamic classes with non-data descriptors for deferred instance loading. 
django/core/serializers/xml_serializer.py