diff options
| author | Tom Christie | 2014-12-10 22:09:24 +0000 | 
|---|---|---|
| committer | Tom Christie | 2014-12-10 22:09:24 +0000 | 
| commit | 9d3810f313123ce48dea48f3c3f0f2cae5816bde (patch) | |
| tree | c3a84070abbf489dd300dcf3b76d2a1bf08e63a7 /rest_framework | |
| parent | ca7b1f6d5189398be8a0d24b1e01577281b1b187 (diff) | |
| download | django-rest-framework-9d3810f313123ce48dea48f3c3f0f2cae5816bde.tar.bz2 | |
Drop get_iterable()
Diffstat (limited to 'rest_framework')
| -rw-r--r-- | rest_framework/relations.py | 9 | 
1 files changed, 3 insertions, 6 deletions
| diff --git a/rest_framework/relations.py b/rest_framework/relations.py index 6b693e4b..a5f97596 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -88,7 +88,7 @@ class RelatedField(Field):          return False      def get_attribute(self, instance): -        if self.use_pk_only_optimization(): +        if self.use_pk_only_optimization() and self.source_attrs:              try:                  # Optimized case, return a mock object only containing the pk attribute.                  instance = get_attribute(instance, self.source_attrs[:-1]) @@ -99,10 +99,6 @@ class RelatedField(Field):          # Standard case, return the object instance.          return get_attribute(instance, self.source_attrs) -    def get_iterable(self, instance, source_attrs): -        relationship = get_attribute(instance, source_attrs) -        return relationship.all() if (hasattr(relationship, 'all')) else relationship -      @property      def choices(self):          return dict([ @@ -349,7 +345,8 @@ class ManyRelatedField(Field):          ]      def get_attribute(self, instance): -        return self.child_relation.get_iterable(instance, self.source_attrs) +        relationship = get_attribute(instance, self.source_attrs) +        return relationship.all() if (hasattr(relationship, 'all')) else relationship      def to_representation(self, iterable):          return [ | 
