diff options
| author | Ahmed Nassar <a.moh.nassar00@gmail.com> | 2025-04-16 17:02:56 +0200 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-04-17 12:30:20 +0200 |
| commit | d469db978ea6a705549b9519313d9adc198e4232 (patch) | |
| tree | 672f7dd015457e78d27e06a1de2faf711c9dd5d4 /django/contrib/auth | |
| parent | 4a293eff6fb10a04de7c65ed705ca3c6a362a587 (diff) | |
Fixed #36314 -- Fixed MinimumLengthValidator error message translation.
Regression in ec7d69035a408b357f1803ca05a7c991cc358cfa.
Thank you Gabriel Trouvé for the report and Claude Paroz for the review.
Diffstat (limited to 'django/contrib/auth')
| -rw-r--r-- | django/contrib/auth/password_validation.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/django/contrib/auth/password_validation.py b/django/contrib/auth/password_validation.py index 6067858b00..38e7c5c3a8 100644 --- a/django/contrib/auth/password_validation.py +++ b/django/contrib/auth/password_validation.py @@ -106,15 +106,20 @@ class MinimumLengthValidator: def validate(self, password, user=None): if len(password) < self.min_length: - raise ValidationError(self.get_error_message(), code="password_too_short") + raise ValidationError( + self.get_error_message(), + code="password_too_short", + params={"min_length": self.min_length}, + ) def get_error_message(self): - return ngettext( - "This password is too short. It must contain at least %d character." - % self.min_length, - "This password is too short. It must contain at least %d characters." - % self.min_length, - self.min_length, + return ( + ngettext( + "This password is too short. It must contain at least %d character.", + "This password is too short. It must contain at least %d characters.", + self.min_length, + ) + % self.min_length ) def get_help_text(self): |
