Opened 17 years ago
Closed 17 years ago
#4385 closed (fixed)
cleaned_data gets set twice even when no clean_<field> method
Reported by: | Owned by: | Adrian Holovaty | |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
newforms/forms.py: (Patch attached)
self.cleaned_data[name] = value
if hasattr(self, 'clean_%s' % name):
value = getattr(self, 'clean_%s' % name)()
self.cleaned_data[name] = value
Attachments (2)
Change History (9)
by , 17 years ago
Attachment: | settingtwice.diff added |
---|
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Yes, you are right. But a comment in the code would be good. Otherwise
this line looks like a typo.
comment:3 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 17 years ago
Yes, this needs to happen twice since the clean_<field>
method needs access to the field's value in cleaned_data
, however it looks like the second assignment could be moved inside the if statement. That way, it's only set twice if there is a clean_<field>
method for the field.
by , 17 years ago
Only assign to cleaned_data
again if we had a clean_<field>
method.
comment:5 by , 17 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:6 by , 17 years ago
Summary: | Typo: value gets set twice → cleaned_data gets set twice even when no clean_<field> method |
---|
comment:7 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Doesn't the clean_ method need access to clean_data containing the cleaned value?