From 3ad0bcdc8839b1bf3cea7cf7f8f571f212261f28 Mon Sep 17 00:00:00 2001 From: Ryan P Kilby Date: Wed, 8 May 2019 19:16:51 -0700 Subject: [PATCH] Fix nullable `source='*'` fields --- rest_framework/fields.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 5e3132074..8fab193e9 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -493,6 +493,11 @@ class Field: if data is None: if not self.allow_null: self.fail('null') + # Nullable `source='*'` fields should not be skipped when its named + # field is given a null value. This is because `source='*'` means + # the field is passed the entire object, which is not null. + elif self.source == '*': + return (False, None) return (True, None) return (False, data)