Django + Postgres:“当前事务被中止,忽略直到事务块结束的命令” [英] Django+Postgres: "current transaction is aborted, commands ignored until end of transaction block"
问题描述
manage.py shell
中工作,并且意外地做了一些导致错误的DB操作。那么我根本无法执行任何数据库操作,因为对于我尝试执行的任何数据库操作,我收到错误: 当前事务中止,忽略事务处理结束前的命令
我的目前的解决方法是重新启动shell,但是我应该找到一种方法来解决这个问题而不放弃我的shell会话。
(我已经阅读这个和这个,但是它们没有提供关于从shell中做什么的可操作的说明
您可以尝试这样:
from django.db import connection
connection._rollback()
更详细的讨论此问题可以在这里找到
I've started working on a Django/Postgres site. Sometimes I work in manage.py shell
, and accidentally do some DB action that results in an error. Then I am unable to do any database action at all, because for any database action I try to do, I get the error:
current transaction is aborted, commands ignored until end of transaction block
My current workaround is to restart the shell, but I should find a way to fix this without abandoning my shell session.
(I've read this and this, but they don't give actionable instructions on what to do from the shell.)
You can try this:
from django.db import connection
connection._rollback()
The more detailed discussion of This issue can be found here
这篇关于Django + Postgres:“当前事务被中止,忽略直到事务块结束的命令”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!