I have many objects to save in the database, so I want to create Model instances with this.
With django, I can create all instances of models with MyModel(data) , and then I want to save all of them.
I currently have something like this:
for item in items: object = MyModel(name=item.name) object.save()
I am wondering if I can save a list of objects directly, for example:
objects = [] for item in items: objects.append(MyModel(name=item.name)) objects.save_all()
How to save all objects in one transaction?
django django-models
Alexis Mรฉtaireau Aug 31 '10 at 11:23 2010-08-31 11:23
source share