diff --git a/rest_framework/fields.py b/rest_framework/fields.py index bb9a523d6..5d13bd55f 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -409,6 +409,13 @@ class BooleanField(WritableField): return False raise ValidationError(self.error_messages['invalid'] % value) +class TextField(WritableField): + type_name = 'TextField' + + def from_native(self, value): + if isinstance(value, basestring) or value is None: + return value + return smart_unicode(value) class CharField(WritableField): type_name = 'CharField' diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 063300172..0f19956eb 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -381,6 +381,7 @@ class ModelSerializer(Serializer): models.DateField: DateField, models.EmailField: EmailField, models.CharField: CharField, + models.TextField: TextField, models.CommaSeparatedIntegerField: CharField, models.BooleanField: BooleanField, }