Django bulk_create a list of lists
<p>As the title indicates, is there a way to bulk_create list of lists. Like right now I bulk_create it like - </p>

<pre><code>for i in range(len(x))   
  arr1 = []
    for m in range(len(y)):
    arr1.append(DataModel(foundation=foundation, date=dates[m], price=price[m]))
  DataModel.objects.bulk_create(arr1)
</code></pre>

<p>Now this will bulk create till the length of x.</p>

<p>Can it be done like so -</p>

<pre><code>arr = []
for i in range(len(x))   
  arr1 = []
    for m in range(len(y)):
    arr1.append(DataModel(foundation=foundation, date=dates[m], price=price[m]))
  arr.append(arr1)
DataModel.objects.bulk_create(arr)
</code></pre>

<p>If not, what else can be done to store data faster?</p>

<p>Append your object to <code>arr</code>, not <code>arr1</code>.<br>
Or you can make flat list before <code>bulk_create</code>:</p>

<pre><code>import itertools
arr = list(itertools.chain(*arr))
</code></pre>

python django