Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed #2761 - ListField truncation on HTTP PATCH
- Checked ``partial`` state when getting value in appropriate field
  classes; return ``empty`` immediately if key not submitted.
  • Loading branch information
adamsc64 committed Sep 19, 2015
commit 9ccfc940775787638848304021744797d837b87a
12 changes: 7 additions & 5 deletions rest_framework/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,14 +1262,13 @@ def __init__(self, *args, **kwargs):
super(MultipleChoiceField, self).__init__(*args, **kwargs)

def get_value(self, dictionary):
if self.field_name not in dictionary:
if getattr(self.root, 'partial', False):
return empty
# We override the default field access in order to support
# lists in HTML forms.
if html.is_html_input(dictionary):
ret = dictionary.getlist(self.field_name)
if getattr(self.root, 'partial', False) and not ret:
ret = empty
return ret

return dictionary.getlist(self.field_name)
return dictionary.get(self.field_name, empty)

def to_internal_value(self, data):
Expand Down Expand Up @@ -1416,6 +1415,9 @@ def __init__(self, *args, **kwargs):
self.child.bind(field_name='', parent=self)

def get_value(self, dictionary):
if self.field_name not in dictionary:
if getattr(self.root, 'partial', False):
return empty
# We override the default field access in order to support
# lists in HTML forms.
if html.is_html_input(dictionary):
Expand Down