diff --git a/rest_framework/relations.py b/rest_framework/relations.py index 3a2a8fb4b..3cd46379d 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -175,8 +175,13 @@ class RelatedField(Field): value = attribute_instance.serializable_value(self.source_attrs[-1]) if is_simple_callable(value): # Handle edge case where the relationship `source` argument - # points to a `get_relationship()` method on the model - value = value().pk + # points to a `get_relationship()` method on the model. + value = value() + + # Handle edge case where relationship `source` argument points + # to an instance instead of a pk (e.g., a `@property`). + value = getattr(value, 'pk', value) + return PKOnlyObject(pk=value) except AttributeError: pass