diff options
Diffstat (limited to 'rest_framework/relations.py')
| -rw-r--r-- | rest_framework/relations.py | 4 | 
1 files changed, 4 insertions, 0 deletions
| diff --git a/rest_framework/relations.py b/rest_framework/relations.py index 0b7c9d86..3a966c5b 100644 --- a/rest_framework/relations.py +++ b/rest_framework/relations.py @@ -360,6 +360,10 @@ class ManyRelatedField(Field):          ]      def get_attribute(self, instance): +        # Can't have any relationships if not created +        if not instance.pk: +            return [] +          relationship = get_attribute(instance, self.source_attrs)          return relationship.all() if (hasattr(relationship, 'all')) else relationship | 
