Skip to content
Home » DatabaseError: current transaction is aborted commands ignored until end of transaction block

DatabaseError: current transaction is aborted commands ignored until end of transaction block

To solve DatabaseError: current transaction is aborted, commands ignored until end of transaction block error follow below methods.

ERROR LOG

DatabaseError: current transaction is aborted, commands ignored until end of transaction block?

How to solve DatabaseError: current transaction is aborted, commands ignored until end of transaction block?

When a query fails and you try to perform another query without first rolling back the transaction, postgres does this. (Think of it as a security feature that prevents your data from being corrupted.)

To solve this, you’ll need to figure out where the incorrect query is being executed in the code. Use the log statement and log min error statement parameters in your Postgresql server if necessary.

Alternative to fix DatabaseError: current transaction is aborted :

To solve the error initially roll back the last transaction 

from django.db import transaction
transaction.rollback()

To avoid the error from occuring, use try-except:

from django.db import transaction, DatabaseError
try:
    x.save()
except DatabaseError:
    transaction.rollback()

Hope the above solution works.

Also read :

TypeError: argument of type ‘int’ is not iterable
Python IOError: [Errno 13] Permission denied While copying file