mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 03:50:11 +03:00
Fix replaced instance being used when pk-only optimization raises AttributeError
This commit is contained in:
parent
fa5ad1d0d9
commit
4d786f8571
|
@ -163,8 +163,8 @@ class RelatedField(Field):
|
|||
if self.use_pk_only_optimization() and self.source_attrs:
|
||||
# Optimized case, return a mock object only containing the pk attribute.
|
||||
try:
|
||||
instance = get_attribute(instance, self.source_attrs[:-1])
|
||||
value = instance.serializable_value(self.source_attrs[-1])
|
||||
attribute_instance = get_attribute(instance, self.source_attrs[:-1])
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user