From bc736c010aeae9ae1df1c3489402f06a6dadf969 Mon Sep 17 00:00:00 2001 From: Michael Ching Date: Fri, 14 Nov 2014 02:10:58 +0000 Subject: [PATCH] allow serialization of blank choice if field is not required --- rest_framework/fields.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 58482db55..6f7381486 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -928,6 +928,10 @@ class ChoiceField(Field): ]) super(ChoiceField, self).__init__(**kwargs) + + if not self.required: + self.choices[''] = '' + self.choice_strings_to_values[''] = '' def to_internal_value(self, data): try: