Now.Zero
Now.Zero

Reputation: 1389

Difference between instantiating models by manager and model-name in Django

When I instantiate the model, I usually used the manager, e.g.

user = User.objects.create_objects(name='Tom', age='25') 

but, sometime I can also see the code like,

user = User(name='Tom', age='25')

Are these two identical codes?

Upvotes: 0

Views: 33

Answers (1)

bruno desthuilliers
bruno desthuilliers

Reputation: 77902

not quite... in the first case the object is immediately written in the database, in the second one it is not until you explicitly save it.

Upvotes: 1

Related Questions