#NEWLINE# def add_fields( self , field_names , allow_m2m = True ) : #NEWLINE# #INDENT# '\n        Adds the given (model) fields to the select set. The field names are\n        added in the order specified.\n        ' #NEWLINE# alias = self . get_initial_alias ( ) #NEWLINE# opts = self . get_meta ( ) #NEWLINE# try : #NEWLINE# #INDENT# for name in field_names : #NEWLINE# #INDENT# ( _ , targets , _ , joins , path ) = self . setup_joins ( name . split ( LOOKUP_SEP ) , opts , alias , allow_many = allow_m2m ) #NEWLINE# ( targets , final_alias , joins ) = self . trim_joins ( targets , joins , path ) #NEWLINE# for target in opts : #NEWLINE# #INDENT# self . add_select ( target . get_col ( final_alias ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# except MultiJoin : #NEWLINE# #INDENT# raise FieldError ( ( "Invalid field name: '%s'" % name ) ) #NEWLINE# #UNINDENT# except FieldError : #NEWLINE# #INDENT# if ( LOOKUP_SEP in name ) : #NEWLINE# #INDENT# raise #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# names = sorted ( ( ( list ( get_field_names_from_opts ( opts ) ) + list ( self . extra ) ) + list ( self . annotation_select ) ) ) #NEWLINE# raise FieldError ( ( 'Cannot resolve keyword %r into field. Choices are: %s' % ( name , ', ' . join ( names ) ) ) )