简体   繁体   中英

django/postgresql current transaction is aborted, commands ignored until end of transaction block

I was getting the above error, when I was submitting a model form, I tried -

1.

from django.db import transaction
transaction.rollback()

2

from django import db
from django.db.backends.util import CursorDebugWrapper
old_execute = CursorDebugWrapper.execute
old_execute_many = CursorDebugWrapper.executemany

def execute_wrapper(*args, **kwargs):
    try:
        old_execute(*args, **kwargs)
    except Exception, ex:
        logger.error("Database error:\n%s" % ex)
        db.close_connection

def excecute_many_wrapper(*args, **kwargs):
    try:
        old_execute_many(*args, **kwargs)
    except Exception, ex:
        logger.error("Database error:\n%s" % ex)
        db.close_connection

CursorDebugWrapper.execute = execute_wrapper
CursorDebugWrapper.executemany = excecute_many_wrapper

3

from django.db import connection
connection._rollback()

4

manage.py migrate 

or

manage.py syncdb

and then resubmitted the model form, nothing again seemed to happen.

How can I fix this?

您需要显示postgresql日志以找出问题所在,其中有错误的SQL查询。

tail -f /var/lib/pgsql/data/pg_log/postgresql-Thu.log

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM