Skip to content

Commit 9d3810f

Browse files
committed
Drop get_iterable()
1 parent ca7b1f6 commit 9d3810f

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

rest_framework/relations.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def use_pk_only_optimization(self):
8888
return False
8989

9090
def get_attribute(self, instance):
91-
if self.use_pk_only_optimization():
91+
if self.use_pk_only_optimization() and self.source_attrs:
9292
try:
9393
# Optimized case, return a mock object only containing the pk attribute.
9494
instance = get_attribute(instance, self.source_attrs[:-1])
@@ -99,10 +99,6 @@ def get_attribute(self, instance):
9999
# Standard case, return the object instance.
100100
return get_attribute(instance, self.source_attrs)
101101

102-
def get_iterable(self, instance, source_attrs):
103-
relationship = get_attribute(instance, source_attrs)
104-
return relationship.all() if (hasattr(relationship, 'all')) else relationship
105-
106102
@property
107103
def choices(self):
108104
return dict([
@@ -349,7 +345,8 @@ def to_internal_value(self, data):
349345
]
350346

351347
def get_attribute(self, instance):
352-
return self.child_relation.get_iterable(instance, self.source_attrs)
348+
relationship = get_attribute(instance, self.source_attrs)
349+
return relationship.all() if (hasattr(relationship, 'all')) else relationship
353350

354351
def to_representation(self, iterable):
355352
return [

0 commit comments

Comments
 (0)