name = 'something'
for hash, color in hashes:
ColorHashes.objects.create(name = name , hash = hash, color = color )
CHUNK_SIZE = 10000 # Подберите наиболее подходящий размер экспериментальным образом
def chunkify(items, chunk_size):
for i in range(0, len(items), chunk_size):
yield items[i:i+chunk_size]
name = 'something'
for chunk in chunkify(hashes, CHUNK_SIZE):
color_hashes = [ColorHashes(name=name , hash=hash, color=color) for hash, color in chunk]
ColorHashes.objects.bulk_create(color_hashes)