Commits

Owen Nelson committed b2f74bd

ensuring empty fields have a None value rather than empty string

  • Participants
  • Parent commits f9261b0

Comments (0)

Files changed (2)

File ipyfield/models.py

 
     def to_python(self, value):
         if not value: 
-            return value
+            return None
         elif isinstance(value, IP):
             return value
         else:
     def get_prep_value(self, value):
         value = self.to_python(value)
         if not value:
-            return value
+            return None
         return value.int()
 
     def get_internal_type(self):

File ipyfield/tests.py

     def setUp(self):
         self.obj = DummyModel()
 
+    def test_empty(self):
+        self.assertEqual(None, self.obj.field)
+
     def test_iptype(self):
         self.obj.field = '127.0.0.1'
         self.assertEqual(self.obj.field.iptype(),'PRIVATE')