diff --git a/rest_framework/fields.py b/rest_framework/fields.py index 8cc8e81ec..24ddb7a44 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: