mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +03:00
fields.get_attribute: return None for FK lookups
Ref: https://github.com/encode/django-rest-framework/pull/5708#issuecomment-355569737
This commit is contained in:
parent
247cf096d4
commit
0a77ff652f
|
@ -98,6 +98,8 @@ def get_attribute(instance, attrs):
|
||||||
instance = instance[attr]
|
instance = instance[attr]
|
||||||
else:
|
else:
|
||||||
instance = getattr(instance, attr)
|
instance = getattr(instance, attr)
|
||||||
|
if instance is None:
|
||||||
|
return None
|
||||||
except ObjectDoesNotExist:
|
except ObjectDoesNotExist:
|
||||||
return None
|
return None
|
||||||
if is_simple_callable(instance):
|
if is_simple_callable(instance):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user