Postgresql – Django+Postgres: “current transaction is aborted, commands ignored until end of transaction block”

djangopostgresql

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.)

Best Answer

You can try this:

from django.db import connection
connection._rollback()

The more detailed discussion of This issue can be found here

Related Topic