Django

Code

Ticket #4291: newforms_widget_smart_unicode.patch

File newforms_widget_smart_unicode.patch, 1.8 kB (added by framos@yaco.es, 2 years ago)

That works for me!

  • widgets.py

    old new  
    168168        for option_value, option_label in chain(self.choices, choices): 
    169169            option_value = smart_unicode(option_value) 
    170170            selected_html = (option_value == str_value) and u' selected="selected"' or '' 
    171             output.append(u'<option value="%s"%s>%s</option>' % (escape(option_value), selected_html, escape(smart_unicode(option_label)))) 
     171            output.append(u'<option value="%s"%s>%s</option>' % (escape(option_value), selected_html, smart_unicode(escape(option_label)))) 
    172172        output.append(u'</select>') 
    173173        return u'\n'.join(output) 
    174174 
     
    205205        for option_value, option_label in chain(self.choices, choices): 
    206206            option_value = smart_unicode(option_value) 
    207207            selected_html = (option_value in str_values) and ' selected="selected"' or '' 
    208             output.append(u'<option value="%s"%s>%s</option>' % (escape(option_value), selected_html, escape(smart_unicode(option_label)))) 
     208            output.append(u'<option value="%s"%s>%s</option>' % (escape(option_value), selected_html, smart_unicode(escape(option_label)))) 
    209209        output.append(u'</select>') 
    210210        return u'\n'.join(output) 
    211211 
     
    288288            cb = CheckboxInput(final_attrs, check_test=lambda value: value in str_values) 
    289289            option_value = smart_unicode(option_value) 
    290290            rendered_cb = cb.render(name, option_value) 
    291             output.append(u'<li><label>%s %s</label></li>' % (rendered_cb, escape(smart_unicode(option_label)))) 
     291            output.append(u'<li><label>%s %s</label></li>' % (rendered_cb, smart_unicode(escape(option_label)))) 
    292292        output.append(u'</ul>') 
    293293        return u'\n'.join(output)