1. Mikhail Korobov
  2. django-colour-field


Matthew Schinckel  committed d5d1846

Handle nullable fields better.

  • Participants
  • Parent commits e97e62a
  • Branches default

Comments (0)

Files changed (1)

File colour_field/fields.py

View file
         return value
     def get_prep_value(self, value):
-        if not value.strip() and self.null:
+        if not (value and value.strip()) and self.null:
             return None
         return value
     def value_to_string(self, value):
-        return value.strip() or None
+        if value:
+            return value.strip() or None
     def formfield(self, *args, **kwargs):
         defaults = {'form_class': ColourFormField}
         return super(ColourField, self).formfield(*args, **defaults)
     def db_type(self, connection):
-        return 'char(7)'
+        return 'char(7)'