#NEWLINE# def serialize_hook( self , instance ) : #NEWLINE# #INDENT# "\n        Serialize the object down to Python primitives.\n\n        By default it uses Django's built in serializer.\n        " #NEWLINE# if ( getattr ( instance , 'serialize_hook' , None ) and callable ( instance . serialize_hook ) ) : #NEWLINE# #INDENT# return instance . serialize_hook ( hook = self ) #NEWLINE# #UNINDENT# if getattr ( settings , 'HOOK_SERIALIZER' , None ) : #NEWLINE# #INDENT# serializer = get_module ( settings . HOOK_SERIALIZER ) #NEWLINE# return serializer ( instance , hook = self ) #NEWLINE# #UNINDENT# data = serializers . serialize ( 'python' , [ instance ] ) [ 0 ] #NEWLINE# for ( k , v ) in data . items ( ) : #NEWLINE# #INDENT# if isinstance ( v , OrderedDict ) : #NEWLINE# #INDENT# data [ k ] = dict ( v ) #NEWLINE# #UNINDENT# #UNINDENT# if isinstance ( data , OrderedDict ) : #NEWLINE# #INDENT# data = dict ( data ) #NEWLINE# #UNINDENT# return { #NEWLINE# #INDENT# 'hook' : self . dict ( ) , #NEWLINE# 'data' : data , #NEWLINE# #UNINDENT# }