Changes between Initial Version and Version 4 of Ticket #5327


Ignore:
Timestamp:
Sep 14, 2007, 7:17:02 AM (17 years ago)
Author:
Malcolm Tredinnick
Comment:

(fixed description formatting)

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #5327

    • Property Owner changed from nobody to Philippe Raoult
    • Property Triage Stage UnreviewedReady for checkin
    • Property Has patch set
    • Property Status newassigned
  • Ticket #5327 – Description

    initial v4  
    1 Using both ChoiceField and ModelChoiceField, I discovered a bug in ChoiceField clean method ( or a discrepancy in behaviour)
     1Using both !ChoiceField and !ModelChoiceField, I discovered a bug in !ChoiceField clean method ( or a discrepancy in behaviour)
    22
    3 ModelChoiceField seems to be working as expected, when I call the clean method in a template like so: form.clean.city , I get the city name(e.g New York), or what would be string inside the tag <select id="5"> New York </select>
     3!ModelChoiceField seems to be working as expected, when I call the clean method in a template like so: form.clean.city , I get the city name(e.g New York), or what would be string inside the tag <select id="5"> New York </select>
    44
    5 This behaviour is different if the values are inside a ChoiceField, if I use the following in the template:  form.clean.city, I get the city id (e.g 5 ), not the expected string or behaviour as using ModelChoiceField.
     5This behaviour is different if the values are inside a !ChoiceField, if I use the following in the template:  form.clean.city, I get the city id (e.g 5 ), not the expected string or behaviour as using !ModelChoiceField.
    66
    7 [NOTE: Not calling the clean field, in either ChoiceField or ModelChoiceField works identcally, generating a select list ]
     7[NOTE: Not calling the clean field, in either !ChoiceField or !ModelChoiceField works identcally, generating a select list ]
    88
    9 I modified the fields.py file in django/newforms, the clean method on the ChoiceField class[line 466], would now read:
    10 
     9I modified the fields.py file in django/newforms, the clean method on the !ChoiceField class[line 466], would now read:
     10{{{
     11#!python
    1112 def clean(self, value):
    1213        """
     
    2526            value = self._choices[int(value)][1]
    2627        return value
    27 
     28}}}
    2829
    2930Only modification is the 'else' at the end, which would assign the value to the actual string.
Back to Top