def insert_many(objects, using="<STR_LIT:default>"):
if not objects:<EOL><INDENT>return<EOL><DEDENT>import django.db.models<EOL>from django.db import connections<EOL>from django.db import transaction<EOL>con = connections[using]<EOL>model = objects[<NUM_LIT:0>].__class__<EOL>fields = [f for f in model._meta.fields<EOL>if not isinstance(f, django.db.models.AutoField)]<EOL>parameters = []<EOL>for o in objects:<EOL><INDENT>params = tuple(f.get_db_prep_save(f.pre_save(o, True), connection=con)<EOL>for f in fields)<EOL>parameters.append(params)<EOL><DEDENT>table = model._meta.db_table<EOL>column_names = "<STR_LIT:U+002C>".join(con.ops.quote_name(f.column) for f in fields)<EOL>placeholders = "<STR_LIT:U+002C>".join(("<STR_LIT:%s>",) * len(fields))<EOL>con.cursor().executemany("<STR_LIT>"<EOL>% (table, column_names, placeholders), parameters)<EOL>transaction.commit_unless_managed(using=using)<EOL>
Insert list of Django objects in one SQL query. Objects must be
    of the same Django model. Note that save is not called and signals
    on the model are not raised.

    Mostly from: http://people.iola.dk/olau/python/bulkops.py