#NEWLINE# def serialize( self , queryset , **options ) : #NEWLINE# #INDENT# '\n        Serialize a queryset.\n        ' #NEWLINE# self . options = options #NEWLINE# self . stream = options . pop ( 'stream' , six . StringIO ( ) ) #NEWLINE# self . selected_fields = options . pop ( 'fields' , None ) #NEWLINE# self . use_natural_keys = options . pop ( 'use_natural_keys' , False ) #NEWLINE# if ( self . use_natural_keys and ( RemovedInDjango19Warning is not None ) ) : #NEWLINE# #INDENT# warnings . warn ( '``use_natural_keys`` is deprecated; use ``use_natural_foreign_keys`` instead.' , RemovedInDjango19Warning ) #NEWLINE# #UNINDENT# self . use_natural_foreign_keys = ( options . pop ( 'use_natural_foreign_keys' , False ) or self . use_natural_keys ) #NEWLINE# self . use_natural_primary_keys = options . pop ( 'use_natural_primary_keys' , False ) #NEWLINE# self . start_serialization ( ) #NEWLINE# self . first = True #NEWLINE# for obj in queryset : #NEWLINE# #INDENT# self . start_object ( queryset ) #NEWLINE# concrete_model = obj . _meta . concrete_model #NEWLINE# for field in concrete_model . _meta . fields : #NEWLINE# #INDENT# if field . serialize : #NEWLINE# #INDENT# if ( field . rel is None ) : #NEWLINE# #INDENT# if ( ( self . selected_fields is None ) or ( field . attname in self . selected_fields ) ) : #NEWLINE# #INDENT# self . handle_field ( obj , field ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( self . selected_fields is None ) or ( field . attname [ : ( - 3 ) ] in self . selected_fields ) ) : #NEWLINE# #INDENT# self . handle_fk_field ( obj , field ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# for field in concrete_model . _meta . many_to_many : #NEWLINE# #INDENT# if field . serialize : #NEWLINE# #INDENT# if ( ( self . selected_fields is None ) or ( field . attname in self . selected_fields ) ) : #NEWLINE# #INDENT# self . handle_m2m_field ( obj , field ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . end_object ( obj ) #NEWLINE# if self . first : #NEWLINE# #INDENT# self . first = False #NEWLINE# #UNINDENT# #UNINDENT# self . end_serialization ( ) #NEWLINE# return self . getvalue ( )