mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-24 16:24:18 +03:00
Fixed #2761 - ListField truncation on HTTP PATCH
- Checked ``partial`` state when getting value in appropriate field classes; return ``empty`` immediately if key not submitted.
This commit is contained in:
parent
cb42b995fa
commit
9ccfc94077
|
@ -1262,14 +1262,13 @@ class MultipleChoiceField(ChoiceField):
|
|||
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):
|
||||
|
@ -1416,6 +1415,9 @@ class ListField(Field):
|
|||
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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user