Ticket #11892: 11892.diff

File 11892.diff, 1.2 KB (added by Colin Copeland, 15 years ago)
  • django/db/models/base.py

     
    336336        return '%s object' % self.__class__.__name__
    337337
    338338    def __eq__(self, other):
    339         return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val()
     339        return (isinstance(other, self.__class__) or isinstance(self, other.__class__)) and self._get_pk_val() == other._get_pk_val()
    340340
    341341    def __ne__(self, other):
    342342        return not self.__eq__(other)
  • tests/modeltests/defer/models.py

     
    189189>>> from django.db.models.loading import cache
    190190>>> cache.app_models['defer'] = {}
    191191
     192# Model instances of the same type and same ID are considered equal
     193# make sure this is true for deferred models as well
     194>>> s1 = Secondary.objects.get(first='x1')
     195>>> s2 = Secondary.objects.defer('second').get(first='x1')
     196>>> s1 == s2
     197True
     198>>> s2 == s1
     199True
     200
    192201"""}
Back to Top