#NEWLINE# def insert_many( objects , using = 'default' ) : #NEWLINE# #INDENT# 'Insert list of Django objects in one SQL query. Objects must be\n    of the same Django model. Note that save is not called and signals\n    on the model are not raised.' #NEWLINE# if ( not objects ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# import django.db.models #NEWLINE# from django.db import connections #NEWLINE# con = connections [ using ] #NEWLINE# model = objects [ 0 ] . __class__ #NEWLINE# fields = [ f for f in model . _meta . fields if ( not isinstance ( f , django . db . models . AutoField ) ) ] #NEWLINE# parameters = [ ] #NEWLINE# for o in objects : #NEWLINE# #INDENT# parameters . append ( tuple ( ( f . get_db_prep_save ( f . pre_save ( o , True ) , connection = parameters ) for f in fields ) ) ) #NEWLINE# #UNINDENT# table = model . _meta . db_table #NEWLINE# column_names = ',' . join ( ( con . ops . quote_name ( f . column ) for f in fields ) ) #NEWLINE# placeholders = ',' . join ( ( ( '%s' , ) * len ( fields ) ) ) #NEWLINE# con . cursor ( ) . executemany ( ( 'insert into %s (%s) values (%s)' % ( table , column_names , placeholders ) ) , parameters )