def format_relationship_links(related_link=None, self_link=None, rel_meta=None, self_meta=None):
 ret = {'links': {}}
 if related_link:
  ret['links'].update({'related': {'href': (related_link or {}), 'meta': (rel_meta or {})}})
 if self_link:
  ret['links'].update({'self': {'href': (self_link or {}), 'meta': (self_meta or {})}})
 return ret

def format_relationship_links ( related_link = None , self_link = None , rel_meta = None , self_meta = None ) : ret = { 'links' : { } } if related_link : ret [ 'links' ] . update ( { 'related' : { 'href' : ( related_link or { } ) , 'meta' : ( rel_meta or { } ) } } ) if self_link : ret [ 'links' ] . update ( { 'self' : { 'href' : ( self_link or { } ) , 'meta' : ( self_meta or { } ) } } ) return ret
properly handles formatting of self and related links according to json api .