mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-26 11:33:59 +03:00
Move comment
This commit is contained in:
parent
9d3810f313
commit
1e336ef30d
|
@ -89,8 +89,8 @@ class RelatedField(Field):
|
||||||
|
|
||||||
def get_attribute(self, instance):
|
def get_attribute(self, instance):
|
||||||
if self.use_pk_only_optimization() and self.source_attrs:
|
if self.use_pk_only_optimization() and self.source_attrs:
|
||||||
try:
|
|
||||||
# Optimized case, return a mock object only containing the pk attribute.
|
# Optimized case, return a mock object only containing the pk attribute.
|
||||||
|
try:
|
||||||
instance = get_attribute(instance, self.source_attrs[:-1])
|
instance = get_attribute(instance, self.source_attrs[:-1])
|
||||||
return PKOnlyObject(pk=instance.serializable_value(self.source_attrs[-1]))
|
return PKOnlyObject(pk=instance.serializable_value(self.source_attrs[-1]))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user