1 Request Method: GET2 Request URL: http://192.168.128.111:8000/xxx/xxxx/3 Django Version: 1.4.84 Exception Type: transactionmanagementerror5Exception Value: 6 Transaction managed block ended with pending commit/rollback
Today, when doing business, this problem always occurs, I studied for half a day, found that my code strictly according to
Try
***
exception
***
Else
***
This format to write, why still wrong?
So all kinds of Google, what comments off @transaction.commit_manually see where the mistake, everything tried.
Until I found this post: Http://stackoverflow.com/questions/9955321/django-transaction-managed-block-ended-with-pending-commit-rollback
Ma but Ah, it turns out that there are database operations before returning to the view.
1retval = Render_to_response ('***/***.html',{2 'form': Form,3 'nav_active':'Active',4 },context)5 Transaction.commit ()6 returnretval
This will be OK.
Django Transaction Error--Transaction managed block ended with pending commit/rollback