diff options
| author | Tom Christie | 2014-12-10 21:09:45 +0000 | 
|---|---|---|
| committer | Tom Christie | 2014-12-10 21:09:45 +0000 | 
| commit | ca7b1f6d5189398be8a0d24b1e01577281b1b187 (patch) | |
| tree | 43892cdb5c9079ee5e2a464cd3e4eae98e755c11 /rest_framework | |
| parent | 720a37d3dedc501968bebaca3a339c72392b9c81 (diff) | |
| download | django-rest-framework-ca7b1f6d5189398be8a0d24b1e01577281b1b187.tar.bz2 | |
Optimizations play nicely with select_related, prefetch_related
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/relations.py | 12 | 
1 files changed, 1 insertions, 11 deletions
| 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): | 
