We are overriding the error messages in the password validators. It can be done by creating new subclasses and overriding the methods that raise the validation errors, or by catching the validation errors that are raised and substituting new messages. Are there any cleaner ways to use custom error messages in password validation?
If not… what if django put the error messages as attributes on the validator classes? Currently, there’s precedent for putting data in a class attribute, so what if the error messages were also put in attributes? Then, they could be overridden in a subclass without having to override whole methods.
Thanks, but this is on the password field of the built-in User model, so we’re not defining the password field ourselves. How would we set the error messages on that field that’s defined in Django itself? And would the built-in auth forms correctly see the custom error messages?
I’ve opened a PR. I ended up adding a method get_error_message (similar to get_help_text), since there are complications with just adding an attribute because of the string template placeholders like verbose_name.