#NEWLINE# def obj_to_dict( obj ) : #NEWLINE# #INDENT# 'serializes obj for a JSON friendly version\n        tries to serialize JSONField\n\n    ' #NEWLINE# data = serializers . serialize ( 'json' , [ obj ] ) #NEWLINE# struct = json . loads ( data ) [ 0 ] #NEWLINE# response = struct [ 'fields' ] #NEWLINE# response [ 'id' ] = response [ 'pk' ] = struct [ 'pk' ] #NEWLINE# response [ 'model' ] = struct [ 'model' ] #NEWLINE# for f in obj . _meta . fields : #NEWLINE# #INDENT# if ( type ( f ) == JSONField ) : #NEWLINE# #INDENT# e = getattr ( obj , f . name ) #NEWLINE# while ( type ( e ) == unicode ) : #NEWLINE# #INDENT# e = json . loads ( e ) #NEWLINE# #UNINDENT# response [ unicode ( f . name ) ] = e #NEWLINE# #UNINDENT# #UNINDENT# return response