Opened 7 years ago

Closed 6 years ago

Last modified 5 years ago

#13000 closed (fixed)

Deprecated code in admin forms triggers string translation too soon

Reported by: lgs Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


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)

lazy-translation-not-so-lazy.diff (1.4 KB) - added by lgs 7 years ago.

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by lgs

comment:1 Changed 7 years ago by jacob

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

comment:2 Changed 7 years ago by paltman

  • Has patch set

comment:3 Changed 6 years ago by jacob

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 6 years ago by jezdez

  • Resolution set to fixed
  • Status changed from new to closed

(In [12785]) Fixed #13000 - Use a dictionary for the error messages definition in user creation and change form. Thanks for the patch, lgs.

comment:5 Changed 5 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

Note: See TracTickets for help on using tickets.
Back to Top