From aa013a428948802dff9c8ca00df3b7af6faf139b Mon Sep 17 00:00:00 2001 From: Marko Tibold Date: Fri, 16 Nov 2012 22:18:57 +0100 Subject: [PATCH] Fixes #421 --- rest_framework/serializers.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index 0f943ac15..e5c057fbe 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -427,6 +427,12 @@ class ModelSerializer(Serializer): kwargs['choices'] = model_field.flatchoices return ChoiceField(**kwargs) + max_length = getattr(model_field, 'max_length', None) + if max_length: + if not isinstance(model_field, models.CharField): + import pdb; pdb.set_trace() + kwargs['max_length'] = max_length + field_mapping = { models.FloatField: FloatField, models.IntegerField: IntegerField,