On Fri, 2007-11-09 at 05:40 +0000, Milan Andric wrote:
> I might be misunderstanding  the documentation about BooleanField.
> http://www.djangoproject.com/documentation/newforms/#booleanfield
> 
> but it seems if i have :
> 
> >>> class Foo(forms.Form):
>     bool = forms.BooleanField(required=True)
> >>> f=Foo({})
> >>> f.is_valid()
> True
> >>>f.cleaned_data
> {'b': False}
> 
> Doesn't that conflict with what the docs say?
> 
> Shouldn't the form give errors and not validate?

Nope. It's a bit tricky, though. The problem is that HTML forms do not
send *anything* for a checkbox that you don't check. So missing data for
a checkbox field means it wasn't checked and is, therefore, False.

We tried making it None for a while, but this was more confusing than
not (you'd never get back False, for a start), so we switched to
treating it as False.

Malcolm

-- 
I just got lost in thought. It was unfamiliar territory. 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to