Deprecated code in admin forms triggers string translation too soon
|Reported by:||Lorenzo Gil Sanchez||Owned by:||nobody|
|Cc:||Triage Stage:||Ready for checkin|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
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.
Change History (6)
comment:1 Changed 7 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|