Skip to content

Commit 0a77ff6

Browse files
blueyedcarltongibson
authored andcommitted
fields.get_attribute: return None for FK lookups
Ref: #5708 (comment)
1 parent 247cf09 commit 0a77ff6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rest_framework/fields.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ def get_attribute(instance, attrs):
9898
instance = instance[attr]
9999
else:
100100
instance = getattr(instance, attr)
101+
if instance is None:
102+
return None
101103
except ObjectDoesNotExist:
102104
return None
103105
if is_simple_callable(instance):

0 commit comments

Comments
 (0)