From 7ed8a480a3b0c4b302a4715feb8f57a1202e202d Mon Sep 17 00:00:00 2001 From: sol HYUN Date: Tue, 6 Dec 2016 00:18:33 +0900 Subject: [PATCH] Create lists only under certain conditions --- rest_framework/fields.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index de279f292..96dfc5831 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -422,7 +422,10 @@ class Field(object): if getattr(self.root, 'partial', False): return empty return self.default_empty_html - ret = dictionary.getlist(self.field_name) + if len(dictionary.getlist(self.field_name)) > 1: + ret = dictionary.getlist(self.field_name) + else: + ret = dictionary.get(self.field_name) if ret == '' and self.allow_null: # If the field is blank, and null is a valid value then # determine if we should use null instead.