Code

Opened 2 years ago

Closed 2 years ago

#17190 closed Bug (fixed)

NullBooleanSelect uses ugettext, should be ugettext_lazy

Reported by: pennersr 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 2 years ago.
patch with tests

Download all attachments as: .zip

Change History (5)

comment:1 Changed 2 years ago by julien

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

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

comment:2 Changed 2 years ago by julien

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'}))

Changed 2 years ago by kenth

patch with tests

comment:3 Changed 2 years ago by kenth

  • Needs tests unset

Added tests to confirm bug & patch.

comment:4 Changed 2 years ago by julien

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

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.