diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-03-13 00:35:47 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-03-13 00:35:47 +0000 |
| commit | 400ee0266149309ccf1d36886c4a8a0524f14efc (patch) | |
| tree | 7611798e5737648d45850cc024b1fd10453006fc | |
| parent | e4e74f7e1d9f8fd7babaa9e0e37298b5f241a2c9 (diff) | |
Added to_python implementation for NullBoolean Fields. This was required for the XML serializer.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4717 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/db/models/fields/__init__.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index e8a2c231c5..1d9f801f39 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -742,6 +742,13 @@ class NullBooleanField(Field): kwargs['null'] = True Field.__init__(self, *args, **kwargs) + def to_python(self, value): + if value in (None, True, False): return value + if value in ('None'): return None + if value in ('t', 'True', '1'): return True + if value in ('f', 'False', '0'): return False + raise validators.ValidationError, gettext("This value must be either None, True or False.") + def get_manipulator_field_objs(self): return [oldforms.NullBooleanField] |
