#NEWLINE# def to_representation( self , obj ) : #NEWLINE# #INDENT# data = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# meta = getattr ( self , 'Meta' , None ) #NEWLINE# type_ = getattr ( meta , 'type_' , None ) #NEWLINE# assert ( type_ is not None ) , 'Must define Meta.type_' #NEWLINE# relation_id_field = self . fields [ 'id' ] #NEWLINE# data [ 'data' ] = None #NEWLINE# if obj . primary_institution : #NEWLINE# #INDENT# attribute = obj . primary_institution . _id #NEWLINE# relationship = relation_id_field . to_representation ( attribute ) #NEWLINE# data [ 'data' ] = { #NEWLINE# #INDENT# 'type' : type_ , #NEWLINE# 'id' : relationship , #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# data [ 'links' ] = { key : val for ( key , val ) in self . fields . get ( 'links' ) . to_representation ( obj ) . iteritems ( ) } #NEWLINE# return data