@@ -88,7 +88,7 @@ def use_pk_only_optimization(self):
88
88
return False
89
89
90
90
def get_attribute (self , instance ):
91
- if self .use_pk_only_optimization ():
91
+ if self .use_pk_only_optimization () and self . source_attrs :
92
92
try :
93
93
# Optimized case, return a mock object only containing the pk attribute.
94
94
instance = get_attribute (instance , self .source_attrs [:- 1 ])
@@ -99,10 +99,6 @@ def get_attribute(self, instance):
99
99
# Standard case, return the object instance.
100
100
return get_attribute (instance , self .source_attrs )
101
101
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
-
106
102
@property
107
103
def choices (self ):
108
104
return dict ([
@@ -349,7 +345,8 @@ def to_internal_value(self, data):
349
345
]
350
346
351
347
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
353
350
354
351
def to_representation (self , iterable ):
355
352
return [
0 commit comments