diff --git a/django/core/validators.py b/django/core/validators.py index fe8d46526ab5..a5641d85b356 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -595,7 +595,8 @@ def __call__(self, value): def __eq__(self, other): return ( isinstance(other, self.__class__) - and self.allowed_extensions == other.allowed_extensions + and set(self.allowed_extensions or []) + == set(other.allowed_extensions or []) and self.message == other.message and self.code == other.code ) diff --git a/tests/validators/tests.py b/tests/validators/tests.py index cf64638ebb8a..cae64045bd3d 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -804,6 +804,10 @@ def test_file_extension_equality(self): FileExtensionValidator(["TXT", "png"]), FileExtensionValidator(["txt", "png"]), ) + self.assertEqual( + FileExtensionValidator(["jpg", "png", "txt"]), + FileExtensionValidator(["txt", "jpg", "png"]), + ) self.assertEqual( FileExtensionValidator(["txt"]), FileExtensionValidator(["txt"], code="invalid_extension"),