• Register
0 votes

Problem :

I am facing a lot of errors with the below message :

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

Whenever I tried to change from the python-psycopg to the python-psycopg2 as my Django project's database engine.

My code remains the same, just unable to know where those errors are coming from ?

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

In my recent experience, the mentioned errors happen this way:

    # transaction on the DB is now bad
    # transaction on db is still very bad
    # raises the transaction error

There is nothing wrong with my second query, but since my real error was caught, so my second query is the one that will raise my very less informative error.

This only happens if my except clause catches the IntegrityError or any other exception from the low level database exception, If you can catch something like DoesNotExist then this error will not show up, as DoesNotExist does not corrupt my transaction.

So the lesson here is don't do the try/except/pass.


If you get above mentioned error while in the interactive shell and you need the quick fix, then simply do this:

from django.db import connection


9 7 4
38,600 points

Related questions

0 votes
1 answer 84 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
asked Nov 14, 2019 peterlaw 6.9k points
0 votes
1 answer 266 views
Problem : I am not very sure how can I fix the below issue I have really no idea about why am I facing below error while trying to do the runserver: Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread ... server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
asked Dec 25, 2019 alecxe 7.5k points
0 votes
1 answer 1.6K views
Problem : I had recently uninstalled the Postgres10 and after that reinstalled the Postgres10. After that I went to run a Node, Express, React application that relies on connecting to a Postgres10 database and also communicates with it using Sequelize. Initially I was unable to ... app at in the browser. Does anyone have any idea what is going wrong? Please suggest me the solution for my error.
asked Nov 22, 2019 peterlaw 6.9k points
0 votes
2 answers 858 views
Problem : I have below error message on the django 1.4: “Dictionary update sequence element #0 has length 1; 2 is required” It happened to me when I tried using a template tag like: `{% for v in values %} It happens too when I try to access ... rendering too. I just restarted the uwsgi and everything works well, but above error comes back later. Has someone an idea to fix this error?
asked Jan 22, 2020 jwilliam 3.9k points
0 votes
1 answer 229 views
Problem : Today I ran into a weird error trying to install Django as follows 'pip3' is not recognized as an internal or external command, operable program or batch file.
asked Nov 15, 2019 peterlaw 6.9k points
1 vote
1 answer 85 views
Problem: I have fundamental knowledge of Django. I have learned Django with the help of online tutorials. Recently I have started working on Django. I have recently tried to upgrade my Django to the Django 1.10. Since then I am often facing below error: TypeError: ... ), ] I have only fundamental knowledge about Django so unable to fix the above error. Kindly help me in fixing above Django error.
asked Jun 8, 2020 Martin K 6.6k points
0 votes
2 answers 362 views
Problem : After upgrading it to Django 1.10, I get below error: “TypeError: view must be a callable or a list/tuple in the case of include().” My urls.py is as below : from django.conf.urls import include, url urlpatterns = [     url(r'^$', 'myapp.views.home' ... r'^contact/$', 'myapp.views.contact'),     url(r'^login/$', 'django.contrib.auth.views.login'), ] How can I fix above error?
asked Jan 23, 2020 jwilliam 3.9k points
0 votes
1 answer 11 views
0 votes
2 answers 340 views
Problem : I am trying to create the table but facing below error “Error: There is no unique constraint matching given keys for referenced table.” How to fix the above error?
asked Jan 21, 2020 jwilliam 3.9k points
0 votes
1 answer 198 views
Problem: The Python language is not sensitive to block structuring of code.
asked Mar 9, 2020 ArifulIslam 5.6k points