Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added to_python implementation for NullBoolean Fields. This was requi…

…red for the XML serializer.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@4717 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 400ee0266149309ccf1d36886c4a8a0524f14efc 1 parent e4e74f7
Russell Keith-Magee authored

Showing 1 changed file with 7 additions and 0 deletions. Show diff stats Hide diff stats

  1. 7  django/db/models/fields/__init__.py
7  django/db/models/fields/__init__.py
@@ -742,6 +742,13 @@ def __init__(self, *args, **kwargs):
742 742
         kwargs['null'] = True
743 743
         Field.__init__(self, *args, **kwargs)
744 744
 
  745
+    def to_python(self, value):
  746
+        if value in (None, True, False): return value
  747
+        if value in ('None'): return None
  748
+        if value in ('t', 'True', '1'): return True
  749
+        if value in ('f', 'False', '0'): return False
  750
+        raise validators.ValidationError, gettext("This value must be either None, True or False.")
  751
+
745 752
     def get_manipulator_field_objs(self):
746 753
         return [oldforms.NullBooleanField]
747 754
 

0 notes on commit 400ee02

Please sign in to comment.
Something went wrong with that request. Please try again.