              for item in data
          ]
  
      def get_attribute(self, instance):
          relationship = get_attribute(instance, self.source_attrs)
          return relationship.all() if (hasattr(relationship, 'all')) else relationship
  
      def to_representation(self, iterable):
          return [
              self.child_relation.to_representation(value)
 
</s>
        # Can't have any relationships if not created
        if not instance.pk:
            return []

              for item in data
          ]
  
      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
  
      def to_representation(self, iterable):
          return [
              self.child_relation.to_representation(value)
keep keep keep add keep keep keep keep keep keep
 Add support for serializing models with m2m related fields

- In both ManyRelatedField, provide an empty return when trying to
  access a relation field if the instance in question has no PK (so
  likely hasn't been inserted yet)
- Add relevant tests
- Without these changes, exceptions would be raised when trying to
  serialize the uncreated models as it is impossible to query
  relations without a PK
- Add test to ensure RelatedField does not regress as currently 
  supports being serialized with and unsaved model
rest_framework/relations.py