diff --git a/rest_framework/exceptions.py b/rest_framework/exceptions.py index 3c64386da6..f79b161294 100644 --- a/rest_framework/exceptions.py +++ b/rest_framework/exceptions.py @@ -91,6 +91,9 @@ def __repr__(self): self.code, )) + def __hash__(self): + return hash(str(self)) + class APIException(Exception): """ diff --git a/tests/test_exceptions.py b/tests/test_exceptions.py index 0c5ff7aae9..ce0ed8514f 100644 --- a/tests/test_exceptions.py +++ b/tests/test_exceptions.py @@ -81,6 +81,10 @@ def test_str(self): assert str(ErrorDetail('msg1')) == 'msg1' assert str(ErrorDetail('msg1', 'code')) == 'msg1' + def test_hash(self): + assert hash(ErrorDetail('msg')) == hash('msg') + assert hash(ErrorDetail('msg', 'code')) == hash('msg') + class TranslationTests(TestCase):
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: