#13000 closed (fixed)
Deprecated code in admin forms triggers string translation too soon
| Reported by: | Lorenzo Gil Sanchez | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.admin | Version: | dev |
| Severity: | Keywords: | ||
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
The forms UserCreationForm and PasswordResetForm of the admin application instantiate a RegexField using deprecated code:
username = forms.RegexField(label=_("Username"), max_length=30, regex=r'^\w+$',
help_text = _("Required. 30 characters or fewer. Alphanumeric characters only (letters, digits and underscores)."),
error_message = _("This value must contain only letters, numbers and underscores."))
This mean that even if the "_" symbol refers to ugettext_lazy the translation is called at import time since the RegexField constructor (indirectly) calls it.
I've attached a patch that solves this problem.
Attachments (1)
Change History (6)
by , 16 years ago
| Attachment: | lazy-translation-not-so-lazy.diff added |
|---|
comment:1 by , 16 years ago
| Triage Stage: | Unreviewed → Accepted |
|---|
comment:2 by , 16 years ago
| Has patch: | set |
|---|
comment:3 by , 16 years ago
| Triage Stage: | Accepted → Ready for checkin |
|---|
comment:4 by , 16 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
(In [12785]) Fixed #13000 - Use a dictionary for the error messages definition in user creation and change form. Thanks for the patch, lgs.