mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +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:
|
||||||
|
# Optimized case, return a mock object only containing the pk attribute.
|
||||||
try:
|
try:
|
||||||
# Optimized case, return a mock object only containing the pk attribute.
|
|
||||||
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