This commit is contained in:
pySilver 2014-06-28 22:01:57 +00:00
commit 17b56efe41

View File

@ -429,6 +429,11 @@ class ModelField(WritableField):
"type": self.model_field.get_internal_type() "type": self.model_field.get_internal_type()
} }
def validate(self, value):
super(ModelField, self).validate(value)
if value is None and not self.model_field.null:
raise ValidationError(self.error_messages['invalid'])
##### Typed Fields ##### ##### Typed Fields #####
@ -474,10 +479,7 @@ class CharField(WritableField):
self.validators.append(validators.MaxLengthValidator(max_length)) self.validators.append(validators.MaxLengthValidator(max_length))
def from_native(self, value): def from_native(self, value):
if isinstance(value, six.string_types): if value in validators.EMPTY_VALUES:
return value
if value is None:
return '' return ''
return smart_text(value) return smart_text(value)