pass value to field specific clean function
newforms has this bit of code in the full_clean function:
try:
value = field.clean(value)
self.clean_data[name] = value
if hasattr(self, 'clean_%s' % name):
value = getattr(self, 'clean_%s' % name)()
self.clean_data[name] = value
except ValidationError, e:
errors[name] = e.messages
Why is value not passed to the clean_%s function? Since it is required to return the accepted value, it is odd that it is forced to look it up. Basicly a dictionary read and assignment is required with no obvious gain. Logically I find it odd as well that clean_data contains values that are not cleaned fully yet.
- 3896.diff
(690 bytes
) - added by Gary Wilson <gary.wilson@…> 18 years ago.
- Pass the value to clean_XXX method and don't save to clean_data first.
- 3896.2.diff
(2.0 KB
) - added by Gary Wilson <gary.wilson@…> 18 years ago.
- Only the passing of value to
clean_XXX
method, with test fixes.
Download all attachments as:
.zip
Description: |
modified (diff)
|
Triage Stage: |
Unreviewed → Design decision needed
|
Has patch: |
set
|
Needs documentation: |
set
|
Needs tests: |
set
|
Resolution: |
→ fixed
|
Status: |
new → closed
|
(cleaning up code formatting in description)