diff options
| author | Tom Christie | 2015-01-28 09:26:49 +0000 |
|---|---|---|
| committer | Tom Christie | 2015-01-28 09:26:49 +0000 |
| commit | 6d89430dd268e01812214d1819337e1498d6068a (patch) | |
| tree | 9a19c7a1af371d6a3ccfde9ac2e45926366add6d /rest_framework | |
| parent | 81c2562ec4a1871a6f5f471ad37799ede3dbc166 (diff) | |
| parent | e7da266a866adddd5c37453fab33812ee412752b (diff) | |
| download | django-rest-framework-6d89430dd268e01812214d1819337e1498d6068a.tar.bz2 | |
Merge pull request #2475 from sdreher/master
ManyRelatedField.get_value clearing field on partial update
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/relations.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/rest_framework/relations.py b/rest_framework/relations.py index aa0c2def..13793f37 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -338,7 +338,12 @@ class ManyRelatedField(Field): # We override the default field access in order to support # lists in HTML forms. if html.is_html_input(dictionary): + # Don't return [] if the update is partial + if self.field_name not in dictionary: + if getattr(self.root, 'partial', False): + return empty return dictionary.getlist(self.field_name) + return dictionary.get(self.field_name, empty) def to_internal_value(self, data): |
