Opened 12 years ago

Closed 12 years ago

#17190 closed Bug (fixed)

NullBooleanSelect uses ugettext, should be ugettext_lazy

Reported by: Raymond Penners Owned by: nobody
Component: Forms Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: yes

Description

See django.forms.widgets:

--- widgets.py.orig	2011-11-10 10:40:05.000000000 +0100
+++ widgets.py.new	2011-11-10 10:41:05.000000000 +0100
@@ -545,7 +545,7 @@
     A Select Widget intended to be used with NullBooleanField.
     """
     def __init__(self, attrs=None):
-        choices = ((u'1', ugettext('Unknown')), (u'2', ugettext('Yes')), (u'3', ugettext('No')))
+        choices = ((u'1', ugettext_lazy('Unknown')), (u'2', ugettext_lazy('Yes')), (u'3', ugettext_lazy('No')))
         super(NullBooleanSelect, self).__init__(attrs, choices)
 
     def render(self, name, value, attrs=None, choices=()):

Attachments (1)

17190.diff (2.1 KB ) - added by kenth 12 years ago.
patch with tests

Download all attachments as: .zip

Change History (5)

comment:1 by Julien Phalip, 12 years ago

Needs tests: set
Triage Stage: UnreviewedAccepted

Thanks for the report. This is correct. Could you provide a test case?

comment:2 by Julien Phalip, 12 years ago

Just a quick note. This problem is happening when a widget is instantiated while a form module is loaded, e.g.:

class CommentForm(forms.Form):
    name = forms.CharField(
                widget=forms.TextInput(attrs={'class':'special'}))

by kenth, 12 years ago

Attachment: 17190.diff added

patch with tests

comment:3 by kenth, 12 years ago

Needs tests: unset

Added tests to confirm bug & patch.

comment:4 by Julien Phalip, 12 years ago

Resolution: fixed
Status: newclosed

In [17091]:

Fixed #17190 -- Ensured that the NullBooleanSelect widget's options get lazily localized. Thanks to pennersr for the report and to kenth for the patch.

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