From 3d08475468c53d510e903bf4d368f218588fbdcc Mon Sep 17 00:00:00 2001 From: Swen Kooij Date: Thu, 9 Mar 2017 11:58:49 +0200 Subject: [PATCH] __eq__ should only compare same types unless it's a string --- localized_fields/localized_value.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/localized_fields/localized_value.py b/localized_fields/localized_value.py index 4df5c33..beb0d1d 100644 --- a/localized_fields/localized_value.py +++ b/localized_fields/localized_value.py @@ -85,6 +85,11 @@ class LocalizedValue: And False when they are not. """ + if not isinstance(other, type(self)): + if isinstance(other, str): + return self.__str__() == other + return False + for lang_code, _ in settings.LANGUAGES: if self.get(lang_code) != other.get(lang_code): return False