Changes between Initial Version and Version 4 of Ticket #5327
- Timestamp:
- Sep 14, 2007, 7:17:02 AM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #5327
- Property Owner changed from to
- Property Triage Stage Unreviewed → Ready for checkin
- Property Has patch set
- Property Status new → assigned
-
Ticket #5327 – Description
initial v4 1 Using both ChoiceField and ModelChoiceField, I discovered a bug inChoiceField clean method ( or a discrepancy in behaviour)1 Using both !ChoiceField and !ModelChoiceField, I discovered a bug in !ChoiceField clean method ( or a discrepancy in behaviour) 2 2 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> 4 4 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 usingModelChoiceField.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. 6 6 7 [NOTE: Not calling the clean field, in either ChoiceField orModelChoiceField works identcally, generating a select list ]7 [NOTE: Not calling the clean field, in either !ChoiceField or !ModelChoiceField works identcally, generating a select list ] 8 8 9 I modified the fields.py file in django/newforms, the clean method on the ChoiceField class[line 466], would now read: 10 9 I modified the fields.py file in django/newforms, the clean method on the !ChoiceField class[line 466], would now read: 10 {{{ 11 #!python 11 12 def clean(self, value): 12 13 """ … … 25 26 value = self._choices[int(value)][1] 26 27 return value 27 28 }}} 28 29 29 30 Only modification is the 'else' at the end, which would assign the value to the actual string.