'A little helper method for bulk_insert to insert the bulk one batch
at a time. Inserts recursively a batch from the front of the bulk and
then _batched_insert() the remaining objects again.'

def _batched_insert(self, objs, fields, batch_size):

    if (not objs):
        return
    ops = connections[self.db].ops
    batch_size = (batch_size or max(ops.bulk_batch_size(fields, objs), 1))
    for batch in [objs[i:(i + batch_size)] for i in range(0, len(objs), batch_size)]:
        self.model._base_manager._insert(batch, fields=fields, using=self.db)
