diff options
Diffstat (limited to 'rest_framework/fields.py')
| -rw-r--r-- | rest_framework/fields.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 8cc8e81e..24ddb7a4 100644 --- a/rest_framework/fields.py +++ b/rest_framework/fields.py @@ -57,6 +57,9 @@ def get_attribute(instance, attrs): Also accepts either attribute lookup on objects or dictionary lookups. """ for attr in attrs: + if instance is None: + # Break out early if we get `None` at any point in a nested lookup. + return None try: instance = getattr(instance, attr) except ObjectDoesNotExist: |
