我收到上述错误,当我提交模型表单时,我尝试了 -
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
然后重新提交模型表格,似乎什么也没发生。
我怎样才能解决这个问题?