code: def get_related_object(self, related_model, related_id_field, obj):
          
          try:
              related_object = self.session.query(related_model)\
                                           .filter(getattr(related_model, related_id_field) == obj['id'])\
                                           .one()
          except NoResultFound:
              raise RelatedObjectNotFound("{}.{}: {} not found".format(related_model.__name__,
                                                                       related_id_field,
                                                                       obj['id']))
  
          return related_object
docs: Get a related object
  
          :param Model related_model: an sqlalchemy model
          :param str related_id_field: the identifier field of the related model
          :param DeclarativeMeta obj: the sqlalchemy object to retrieve related objects from
          :return DeclarativeMeta: a related object