From ca7b1f6d5189398be8a0d24b1e01577281b1b187 Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Wed, 10 Dec 2014 21:09:45 +0000 Subject: Optimizations play nicely with select_related, prefetch_related --- rest_framework/relations.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'rest_framework') diff --git a/rest_framework/relations.py b/rest_framework/relations.py index ae4086ec..6b693e4b 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -101,17 +101,7 @@ class RelatedField(Field): def get_iterable(self, instance, source_attrs): relationship = get_attribute(instance, source_attrs) - relationship = relationship.all() if (hasattr(relationship, 'all')) else relationship - - if self.use_pk_only_optimization(): - # Optimized case, return mock objects only containing the pk attribute. - return [ - PKOnlyObject(pk=pk) - for pk in relationship.values_list('pk', flat=True) - ] - - # Standard case, return the object instances. - return relationship + return relationship.all() if (hasattr(relationship, 'all')) else relationship @property def choices(self): -- cgit v1.2.3