Ticket #11892: 11892.diff
File 11892.diff, 1.2 KB (added by , 15 years ago) |
---|
-
django/db/models/base.py
336 336 return '%s object' % self.__class__.__name__ 337 337 338 338 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() 340 340 341 341 def __ne__(self, other): 342 342 return not self.__eq__(other) -
tests/modeltests/defer/models.py
189 189 >>> from django.db.models.loading import cache 190 190 >>> cache.app_models['defer'] = {} 191 191 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 197 True 198 >>> s2 == s1 199 True 200 192 201 """}