From 30f5413d9ec52311473b95dfdca40b9a5f79e652 Mon Sep 17 00:00:00 2001 From: Jens Timmerman Date: Tue, 2 Feb 2016 15:44:07 +0100 Subject: [PATCH] Also handle own permission denied exception Not only should `django.core.exceptions.PermissionDenied` result in a 403_FORBIDDEN, but make this also happen for our own `rest_framework.exceptions.PermissionDenied ` --- rest_framework/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework/views.py b/rest_framework/views.py index 56e3c4e49..a5b8f3351 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -84,7 +84,7 @@ def exception_handler(exc, context): set_rollback() return Response(data, status=status.HTTP_404_NOT_FOUND) - elif isinstance(exc, PermissionDenied): + elif isinstance(exc, PermissionDenied) or isinstance(exc, exceptions.PermissionDenied): msg = _('Permission denied.') data = {'detail': six.text_type(msg)}