Ticket #16458: 16458.diff

File 16458.diff, 1.4 KB (added by Anssi Kääriäinen, 8 years ago)
  • django/db/models/base.py

    diff --git a/django/db/models/base.py b/django/db/models/base.py
    index 71fd1f7..fba040f 100644
    a b class ModelBase(type): 
    3939        # Create the class.
    4040        module = attrs.pop('__module__')
    4141        new_class = super_new(cls, name, bases, {'__module__': module})
     42        new_class._real_class = new_class
    4243        attr_meta = attrs.pop('Meta', None)
    4344        abstract = getattr(attr_meta, 'abstract', False)
    4445        if not attr_meta:
    class Model(object): 
    382383        return '%s object' % self.__class__.__name__
    383384
    384385    def __eq__(self, other):
    385         return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val()
     386        return self._real_class == other._real_class and self._get_pk_val() == other._get_pk_val()
    386387
    387388    def __ne__(self, other):
    388389        return not self.__eq__(other)
  • django/db/models/query_utils.py

    diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
    index a56ab5c..b4e63e3 100644
    a b def deferred_class_factory(model, attrs): 
    162162    overrides["Meta"] = Meta
    163163    overrides["__module__"] = model.__module__
    164164    overrides["_deferred"] = True
     165    overrides["_real_class"] = model
    165166    return type(name, (model,), overrides)
    166167
    167168# The above function is also used to unpickle model instances with deferred
Back to Top