diff --git a/django/core/validators.py b/django/core/validators.py index fe8d46526a..a5641d85b3 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -595,7 +595,8 @@ class FileExtensionValidator: 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 cf64638ebb..cae64045bd 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -804,6 +804,10 @@ class TestValidatorEquality(TestCase): 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"),