#3896 closed (fixed)
pass value to field specific clean function
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 (last modified by )
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.
Attachments (2)
Change History (10)
comment:1 by , 18 years ago
Description: | modified (diff) |
---|
comment:2 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
Seems logical to me. I think it is certainly a bug that clean_data
will retain the value even if clean_XXX
raises a ValidationError
. So even if it is decided that value
shouldn't be passed to clean_XXX
, we at least need to fix the clean_data
problem.
by , 18 years ago
Pass the value to clean_XXX method and don't save to clean_data first.
comment:3 by , 18 years ago
Has patch: | set |
---|---|
Needs documentation: | set |
Needs tests: | set |
by , 17 years ago
Attachment: | 3896.2.diff added |
---|
Only the passing of value to clean_XXX
method, with test fixes.
comment:4 by , 17 years ago
If this change goes in, then also consider removing the line specified in the first patch, which would fix #4391.
comment:5 by , 17 years ago
Needs tests: | unset |
---|
comment:6 by , 17 years ago
Cc: | added |
---|
comment:7 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
it's really an implementation detail, but none the less fixed in [5346].
comment:8 by , 16 years ago
Cc: | added |
---|
(cleaning up code formatting in description)