From 55c44fc92192f63867c6c7ebcb7f75bf0569c900 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 7 Nov 2014 14:13:50 +0000 Subject: [PATCH] Fix serializer initial data --- rest_framework/serializers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rest_framework/serializers.py b/rest_framework/serializers.py index b00f9b7a8..833a4e486 100644 --- a/rest_framework/serializers.py +++ b/rest_framework/serializers.py @@ -230,7 +230,11 @@ class Serializer(BaseSerializer): def get_initial(self): if self._initial_data is not None: - return self.to_representation(self._initial_data) + return ReturnDict([ + (field_name, field.get_value(self._initial_data)) + for field_name, field in self.fields.items() + if field.get_value(self._initial_data) is not empty + ], serializer=self) return ReturnDict([ (field.field_name, field.get_initial())