mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 20:10:10 +03:00
Merge 7d9f1b7878
into 8eadac39ad
This commit is contained in:
commit
17b56efe41
|
@ -429,6 +429,11 @@ class ModelField(WritableField):
|
|||
"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 #####
|
||||
|
||||
|
@ -474,10 +479,7 @@ class CharField(WritableField):
|
|||
self.validators.append(validators.MaxLengthValidator(max_length))
|
||||
|
||||
def from_native(self, value):
|
||||
if isinstance(value, six.string_types):
|
||||
return value
|
||||
|
||||
if value is None:
|
||||
if value in validators.EMPTY_VALUES:
|
||||
return ''
|
||||
|
||||
return smart_text(value)
|
||||
|
|
Loading…
Reference in New Issue
Block a user