[Django] #37202: MinimumLengthValidator.get_error_message has a bug that breaks translation

6 views
Skip to first unread message

Django

unread,
Jul 3, 2026, 9:47:47 AM (15 hours ago) Jul 3
to django-...@googlegroups.com
#37202: MinimumLengthValidator.get_error_message has a bug that breaks translation
----------------------------------------+--------------------------
Reporter: meng | Owner: (none)
Type: Bug | Status: assigned
Component: contrib.auth | Version: 5.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+--------------------------
Hello,
The get_error_message method of the MinimumLengthValidator class in
Django's auth password_validation.py file has a bug that prevents
translations from working correctly.

The problem code is:

{{{
class MinimumLengthValidator:
...
def get_error_message(self):
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
)
}}}


The correct code should be:
{{{
class MinimumLengthValidator:
...
def get_error_message(self):
return (
ngettext(
"This password is too short. It must contain at least
%(min_length)d character.",
"This password is too short. It must contain at least
%(min_length)d characters.",
self.min_length,
)
% {"min_length": self.min_length}
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37202>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 3, 2026, 9:49:01 AM (15 hours ago) Jul 3
to django-...@googlegroups.com
#37202: MinimumLengthValidator.get_error_message has a bug that breaks translation
------------------------------+--------------------------------------
Reporter: meng | Owner: (none)
Type: Bug | Status: assigned
Component: contrib.auth | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by meng):

* Attachment "password_validation.py" added.

Django

unread,
Jul 3, 2026, 11:07:59 AM (13 hours ago) Jul 3
to django-...@googlegroups.com
#37202: MinimumLengthValidator.get_error_message has a bug that breaks translation
------------------------------+--------------------------------------
Reporter: meng | Owner: (none)
Type: Bug | Status: closed
Component: contrib.auth | Version: 5.2
Severity: Normal | Resolution: duplicate
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------+--------------------------------------
Changes (by meng):

* resolution: => duplicate
* status: assigned => closed

--
Ticket URL: <https://code.djangoproject.com/ticket/37202#comment:1>
Reply all
Reply to author
Forward
0 new messages