Programmers learn & share
0 votes
50 views

Problem :

I am having hell lot of troubles because of below error message
internalerror: current transaction is aborted, commands ignored until end of transaction block
by (6.9k points)   | 50 views

1 Answer

0 votes

Solution :

To get rid of the your error, you need to roll back the last erroneous transaction after you have fixed your code.

e.g.
from django.db import transaction
transaction.rollback()

Now you can use try-except to prevent the error from occurring:

e.g.
from django.db import transaction, DatabaseError
try:
    a.save(
except DatabaseError:
    transaction.rollback()

by (36.1k points)  
2,204 questions
2,602 answers
59 comments
241 users