Opened 11 years ago
Closed 11 years ago
#21767 closed Bug (invalid)
Invalid usage of ugettext in BaseForm.__init__
Reported by: | Anssi Kääriäinen | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The line
self.label_suffix = label_suffix if label_suffix is not None else _(':')
in django.forms.forms.BaseForm.init uses ugettext(). To me it seems it should use ugettext_lazy as that line will be called when the model is defined. This means that the default language is used for translation instead of the use-time language. Using ugettext_lazy() should solve the issue.
Note:
See TracTickets
for help on using tickets.
I don't believe this is an issue.
Form.__init__
is surely not called at module time - it's not a metaclasses'__new__
which is called when the form is defined. The method takesdata
andfiles
which are naturally user specified data, so it must be called during a response cycle.Also with the app loading changes to import sequence, these errors tend to blow up now if
ugettext
is called at module level.