how to use transaction of mysql in “save_model” and “delete_model” of django admin

限于喜欢 提交于 2020-01-05 07:45:53

问题


class DispatchAdmin(admin.ModelAdmin):

def delete_model(self, request, obj):
    a.delete()
    b.delete()

def save_model(self,request,obj,form,change):
    x.save()
    y.save()

________How can I________

how can I make the operation to the mysql database as a atomic operation by using the transaction? what should be "import",and if the action is failed, how to rollback?(notes:since I use django admin,there is no extra views.py)

来源:https://stackoverflow.com/questions/19003442/how-to-use-transaction-of-mysql-in-save-model-and-delete-model-of-django-adm

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