code: def get_relationship(self, relationship_field, related_type_, related_id_field, view_kwargs):
          
          self.before_get_relationship(relationship_field, related_type_, related_id_field, view_kwargs)
  
          obj = self.get_object(view_kwargs)
  
          if obj is None:
              url_field = getattr(self, 'url_field', 'id')
              filter_value = view_kwargs[url_field]
              raise ObjectNotFound('{}: {} not found'.format(self.model.__name__, filter_value),
                                   source={'parameter': url_field})
  
          if not hasattr(obj, relationship_field):
              raise RelationNotFound("{} has no attribute {}".format(obj.__class__.__name__, relationship_field))
  
          related_objects = getattr(obj, relationship_field)
  
          if related_objects is None:
              return obj, related_objects
  
          self.after_get_relationship(obj, related_objects, relationship_field, related_type_, related_id_field,
                                      view_kwargs)
  
          if isinstance(related_objects, InstrumentedList):
              return obj,\
                  [{'type': related_type_, 'id': getattr(obj_, related_id_field)} for obj_ in related_objects]
          else:
              return obj, {'type': related_type_, 'id': getattr(related_objects, related_id_field)}
docs: Get a relationship
  
          :param str relationship_field: the model attribute used for relationship
          :param str related_type_: the related resource type
          :param str related_id_field: the identifier field of the related model
          :param dict view_kwargs: kwargs from the resource view
          :return tuple: the object and related object(s)