[英]django - current transaction is aborted, commands ignored until end of transaction block
[英]django/postgresql current transaction is aborted, commands ignored until end of transaction block
我收到上述错误,在提交模型表格时,我尝试了-
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
要么
manage.py syncdb
然后重新提交模型表格,似乎什么也没有发生。
我怎样才能解决这个问题?
您需要显示postgresql日志以找出问题所在,其中有错误的SQL查询。
tail -f /var/lib/pgsql/data/pg_log/postgresql-Thu.log
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.