Opened 18 years ago
Last modified 16 years ago
#3896 closed
pass value to field specific clean function — at Initial Version
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | tailofthesun@…, hv@… | Triage Stage: | Design decision needed |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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.