I just noticed in recent versions of Django that BooleanField
(null=True) will raise a validation warning, indicating that I should
use NullBooleanField instead. This doesn't make sense, and is mixing
up the definition of a model field in SQL and the behaviour of a model
field in Django.

BooleanField(null=True) indicates that the field can have null values
in the database (or does already have null values in the case of an
existing database), but that any objects created or edited via Django
must specify one of two values, true or false.

NullBooleanField() indicates that the field can have null values in
the database and that any objects created or edited via Django must
specify one of three values, null, true, or false.

The difference between the two fields is in presenting two or three
valid choices to users, and the difference between null=True and
null=False is in the database table definition.

This is a backwards incompatible change in behaviour. Apps which
previously used BooleanField(null=True) can no longer perform
`syncdb`, which should be valid.

The initial bug report was in BooleanField's `to_python` method, not
the actual definition of BooleanField(null=True).

Currently it appears that there is no way to specify that the database
contains null values for BooleanField, but that Django should require
true or false when creating or editing.

To draw a parallel with CharField, this recent change is equivalent to
making CharField(blank=False, null=True) invalid.

http://code.djangoproject.com/changeset/10456
http://code.djangoproject.com/ticket/5563

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

Reply via email to