Django

Code

Changeset 4924

Show
Ignore:
Timestamp:
04/04/07 08:52:35 (2 years ago)
Author:
mtredinnick
Message:

Fixed #3597 -- Fixed unicode encoding problem in form rendering. Thanks,
Georgi Stanojevski and Ville Säävuori.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/newforms/forms.py

    r4918 r4924  
    66from django.utils.html import escape 
    77from django.utils.encoding import StrAndUnicode 
     8from django.conf import settings 
    89from fields import Field 
    910from widgets import TextInput, Textarea, HiddenInput, MultipleHiddenInput 
     
    231232            # "special" object rather than a string. Call the __str__() on that 
    232233            # object to get its rendered value. 
    233             value = value.__str__() 
     234            value = value.__unicode__() 
    234235        return value 
    235236 
  • django/trunk/tests/regressiontests/forms/regressions.py

    r4904 r4924  
    1212u'<p>F1: <input type="text" class="special" name="f1" maxlength="10" /></p>\n<p>F2: <input type="text" class="special" name="f2" /></p>' 
    1313 
    14 #######################  
    15 # Tests for form i18n #  
    16 #######################  
     14####################### 
     15# Tests for form i18n # 
     16####################### 
    1717There were some problems with form translations in #3600 
    18   
     18 
    1919>>> from django.utils.translation import gettext_lazy, activate, deactivate 
    2020>>> class SomeForm(Form): 
     
    2727<p><label for="id_username">Benutzername:</label> <input id="id_username" type="text" name="username" maxlength="10" /></p> 
    2828>>> deactivate() 
     29 
     30Unicode decoding problems... 
     31>>> GENDERS = (('0', u'En tied\xe4'), ('1', u'Mies'), ('2', u'Nainen')) 
     32>>> class SomeForm(Form): 
     33...     somechoice = ChoiceField(choices=GENDERS, widget=RadioSelect()) 
     34>>> f = SomeForm() 
     35>>> f.as_p() 
     36u'<p><label for="id_somechoice_0">Somechoice:</label> <ul>\n<li><label><input type="radio" id="id_somechoice_0" value="0" name="somechoice" /> En tied\xe4</label></li>\n<li><label><input type="radio" id="id_somechoice_1" value="1" name="somechoice" /> Mies</label></li>\n<li><label><input type="radio" id="id_somechoice_2" value="2" name="somechoice" /> Nainen</label></li>\n</ul></p>' 
    2937"""