Commits

Matthew Schinckel committed e97e62a

Convert empty string to NULL for storage.

  • Participants
  • Parent commits 5b94f3d

Comments (0)

Files changed (1)

colour_field/fields.py

         # assert re.match('#[0-9a-fA-F]{6}', value)
         return value
     
+    def get_prep_value(self, value):
+        if not value.strip() and self.null:
+            return None
+        return value
+    
+    def value_to_string(self, value):
+        return value.strip() or None
+        
     def formfield(self, *args, **kwargs):
         defaults = {'form_class': ColourFormField}
         defaults.update(kwargs)