Django: Difference between save() and create() from transaction perspective

烈酒焚心 提交于 2019-11-30 02:06:17
Tomasz Zieliński

As you've probably seen, create() is just a wrapper for save():

The _for_write part is most probably meant only for database selection, so I wouldn't pay too much attention to it.

And regarding that "transaction aborted" error, without seeing your code it's hard to say what the problem is. Maybe you e.g. violated UNIQUE constraint with create(), which causes PostgreSQL to demand transaction rollback, and then you tried save() with different data - it's hard to tell without the exact code.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!