Opened 17 years ago

Last modified 15 years ago

#3896 closed

pass value to field specific clean function — at Version 1

Reported by: Henrik Vendelbo <info@…> 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 James Bennett)

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.

Change History (1)

comment:1 by James Bennett, 17 years ago

Description: modified (diff)

(cleaning up code formatting in description)

Note: See TracTickets for help on using tickets.
Back to Top