Ticket #14492: model_eq_14233.diff

File model_eq_14233.diff, 1.0 KB (added by Byron Ruth, 14 years ago)
  • django/db/models/base.py

     
    370370        return '%s object' % self.__class__.__name__
    371371
    372372    def __eq__(self, other):
    373         return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val()
     373        if isinstance(other, self.__class__):
     374            return self._get_pk_val() == other._get_pk_val()
    374375
     376        # self is proxy, other is not
     377        proxy = self._meta.proxy_for_model
     378        if self._meta.proxy is True and isinstance(other, proxy):
     379            return self._get_pk_val() == other._get_pk_val()
     380
     381        # other is proxy, self is not
     382        proxy = other._meta.proxy_for_model
     383        if other._meta.proxy is True and isinstance(self, proxy):
     384            return self._get_pk_val() == other._get_pk_val()
     385        return False
     386
    375387    def __ne__(self, other):
    376388        return not self.__eq__(other)
    377389
Back to Top