Merge pull request #5970 from jangsutsr/5628_update_ctit_serializer_fields_to_handle_html_cornercase

Update CTinT serializer integer field to handle html cornercase
This commit is contained in:
Aaron Tan
2017-04-17 11:21:02 -04:00
committed by GitHub

View File

@@ -31,6 +31,16 @@ class CharField(CharField):
return super(CharField, self).to_representation(value)
class IntegerField(IntegerField):
def get_value(self, dictionary):
ret = super(IntegerField, self).get_value(dictionary)
# Handle UI corner case
if ret == '' and self.allow_null and not getattr(self, 'allow_blank', False):
return None
return ret
class StringListField(ListField):
child = CharField()