diff options
| author | Tom Christie | 2014-11-05 10:28:34 +0000 | 
|---|---|---|
| committer | Tom Christie | 2014-11-05 10:28:34 +0000 | 
| commit | 26b6180f5047e965383553177cd5cd7938bbe63e (patch) | |
| tree | 9ce6740963803dc1999f675817f633621861024c /rest_framework/fields.py | |
| parent | c70242c35bccd1d0c641ba6b4e3f7b62ec11ffb6 (diff) | |
| download | django-rest-framework-26b6180f5047e965383553177cd5cd7938bbe63e.tar.bz2 | |
Support None if initial part of dotted lookup returns None. Closes #1223.
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: | 
