Skip to content

Commit 0a77ff6

Browse files
blueyedcarltongibson
authored andcommitted
fields.get_attribute: return None for FK lookups
Ref: encode#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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy