类似于get_or_create
,我希望能在Django 到update_or_create
.
到目前为止,我一直在使用一种类似于@Daniel Roseman does it here的接近方式.但是,作为一种模型方法,我想更简洁地这样做.
This snippet已经相当老了,我想知道在新版本的Django中有没有更好的方法来做到这一点.
类似于get_or_create
,我希望能在Django 到update_or_create
.
到目前为止,我一直在使用一种类似于@Daniel Roseman does it here的接近方式.但是,作为一种模型方法,我想更简洁地这样做.
This snippet已经相当老了,我想知道在新版本的Django中有没有更好的方法来做到这一点.
参见QuerySet.update_or_create
(Django 1.7dev中的新功能)