Django Model() 与 Model.objects.create() - Django Model() vs Model.objects.create()

问题:

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?第二个是否立即在数据库中创建一个BarModel ,而对于FooModel ,必须显式调用save()方法才能将其添加到数据库中?


解决方案:

参考一: https://stackoom.com/question/1nucn
参考二: Django Model() vs Model.objects.create()
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章