1. Kevin Wetzels
  2. django-stdfields


Kevin Wetzels  committed 46786dc

Fix error in form field that did not allow empty values to be passed in

  • Participants
  • Parent commits 2db724f
  • Branches default

Comments (0)

Files changed (2)

File stdfields/forms.py

View file
         super(MinutesField, self).__init__(*args, **kwargs)
     def clean(self, value):
+        if not value:
+            return super(MinutesField, self).clean(value)
         value = smart_str(value).strip()
         match = re.search(r'^(\d+):(\d{1,2})$', value)
         if match:

File stdfields/tests.py

View file
         minutes = 480
         for i in range(60):
             self.assertEqual(minutes + i, f.clean('8:%d' % (i)))
+        # No errors on empty value when the field is not required
+        f.required = False
+        f.clean(None)
     def test_minutes_field_invalid(self):
         f = MinutesFormField()