Adding transaction rollback to exception_handler

This PR is to show you the idea, there are other ways to implement it (like, for example, another exception class named RollbackAPIException), anyway I find the interference of APIException capture with the rollback of django transaction middleware on exceptions, a little bit dangerous.

If you find it useful, I can implement with the RollbackAPIException, which is more backward compatible.
We ought to put branching code like this in compat.