Answer the question
In order to leave comments, you need to log in
How to properly generate ORM objects?
I wanted to generate objects for educational purposes. The action is understandable
for i in range(1000):
r = Post()
....
r.save()
Answer the question
In order to leave comments, you need to log in
Если цель - создавать объекты, то нет ничего быстрее bulk_create. Немного измени твой код, вот так:
posts = []
for i in range(1000):
r = Post()
....
posts.append(r)
Post.objects.bulk_create(posts)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question