10👍
✅
You obtain the value in a dictionary for the corresponding key by subscripting, like:
objs = [CounterFileData(date=row['date'], value=row['value']) for row in parsed_data]
Furthermore you passed parsed_data
to the list(..)
constructor, whereas it should be objs
. By using list comprehension however, we can omit that.
batch = [CounterFileData(date=row['date'], value=row['value']) for row in parsed_data]
CounterFileData.objects.bulk_create(batch)
Source:stackexchange.com