Created
February 23, 2016 09:31
-
-
Save EnTeQuAk/6c67bc978f976b81ab50 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def __eq__(self, other): | |
- return isinstance(other, self.__class__) and self._get_pk_val() == other._get_pk_val() | |
+ if not isinstance(other, Model): | |
+ return False | |
+ if self._meta.concrete_model != other._meta.concrete_model: | |
+ return False | |
+ my_pk = self._get_pk_val() | |
+ if my_pk is None: | |
+ return self is other | |
+ return my_pk == other._get_pk_val() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment