Issue
What it the difference between running two commands:
foo = FooModel()
and
bar = BarModel.objects.create()
Does the second one immediately create a BarModel
in the database, while for FooModel
, the save()
method has to be called explicitly to add it to the database?
Solution
https://docs.djangoproject.com/en/stable/topics/db/queries/#creating-objects
To create and save an object in a single step, use the
create()
method.
Answered By - madzohan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.