diff --git a/rest_framework/compat.py b/rest_framework/compat.py index c3d100c76..e0f718ced 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -299,6 +299,12 @@ except ImportError: DecimalValidator = None class CustomValidatorMessage(object): + """ + We need to avoid evaluation of `lazy` translated `message` in `django.core.validators.BaseValidator.__init__`. + https://github.com/django/django/blob/75ed5900321d170debef4ac452b8b3cf8a1c2384/django/core/validators.py#L297 + + Ref: https://github.com/encode/django-rest-framework/pull/5452 + """ def __init__(self, *args, **kwargs): self.message = kwargs.pop('message', self.message) super(CustomValidatorMessage, self).__init__(*args, **kwargs)