def create_relationship(model, instance, relation):
 result = {}
 pk_value = primary_key_value(instance)
 self_link = url_for(model, pk_value, relation, relationship=True)
 related_link = url_for(model, pk_value, relation)
 result['links'] = {'self': self_link}
 try:
  related_model = get_related_model(model, relation)
  url_for(related_model)
 except ValueError:
  pass
 else:
  result['links']['related'] = related_link
 related_value = getattr(instance, relation)
 if is_like_list(instance, relation):
  result['data'] = list(map(simple_relationship_dump, related_value))
 elif (related_value is not None):
  result['data'] = simple_relationship_dump(related_value)
 else:
  result['data'] = None
 return result

def create_relationship ( model , instance , relation ) : result = { } pk_value = primary_key_value ( instance ) self_link = url_for ( model , pk_value , relation , relationship = True ) related_link = url_for ( model , pk_value , relation ) result [ 'links' ] = { 'self' : self_link } try : related_model = get_related_model ( model , relation ) url_for ( related_model ) except ValueError : pass else : result [ 'links' ] [ 'related' ] = related_link related_value = getattr ( instance , relation ) if is_like_list ( instance , relation ) : result [ 'data' ] = list ( map ( simple_relationship_dump , related_value ) ) elif ( related_value is not None ) : result [ 'data' ] = simple_relationship_dump ( related_value ) else : result [ 'data' ] = None return result
creates a relationship from the given relation name .