谁能告诉我在这个 Django 中间件中收到警告背后的实际原因,我该如何解决这个问题?
我收到这条消息“ DeprecationWarning: BaseException.message has been deprecated as of Python 2.6 exception.class , exception.message , ”
class GeneralMiddleware(object):
def process_exception(self, request, exception):
if exception.__class__ is SandboxError:
# someone is trying to access a sandbox that he has no
# permission to
return HttpResponseRedirect("/notpermitted/")
exc_type, value, tb = sys.exc_info()
data = traceback.format_tb(
tb, None) + traceback.format_exception_only(
exc_type, value)
msg = (
"Failure when calling method:\n"
u"URL:'%s'\nMethod:'%s'\nException Type:'%s'\n"
u"Error Message '%s'\nFull Message:\n%s"
% (request.get_full_path(), request.method,
exception.__class__, exception.message,