Daniel, I'm afraid it's just inexperience / ignorance that makes me
think that I was no longer dealing with a dictionary.  I saw get() and
went to the model in my mind.  I looked at the source code for the
forms module and it didn't seem that it was all of a sudden not a
dictionary, and your response helps clarify the issue.  Thank you very
much for your help.

I was reading the doc page, "Form and field validation" and saw the
difference in the two clean methods.  It tripped me up for a bit, but
I guess this different method of accessing clean_data makes good
sense.  It seems that clean_fieldname() will always return
cleaned_data for all fields; if the field didn't pass validation it
will still be returned as a python object, with the associated
error(s).  On the other hand, clean() for the form will only return
fields in cleaned_data that have passed all their validation.

One gets a hint of this from the documentation:

"The clean() method for the Form class or subclass is always run.  If
that method raises a ValidationError, cleaned_data will be an empty
dictionary.

The previous paragraph means that if you are overriding Form.clean(),
you should iterate through self.cleaned_data.items(), possibly
considering the _errors dictionary attribute on the form as well.  In
this way, you will already know which fields have passed their
individual validation requirements."

I think this could have been a bit more explicit, but I might not have
looked in the right spot for all the information.

Thanks again, Daniel.

Robin

Ah!  So, it the clean_fieldname method

On Jun 2, 2:32 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> What makes you think that? .get() is a dictionary method. It's just useful 
> when you're not sure the specific key exists, which is the case in the 
> general clean() method.
> --
> DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to