diff --git a/docs/api-guide/views.md b/docs/api-guide/views.md index 55f6664e0..c0c4f67e4 100644 --- a/docs/api-guide/views.md +++ b/docs/api-guide/views.md @@ -73,6 +73,8 @@ The following methods are used by REST framework to instantiate the various plug ### .get_content_negotiator(self) +### .get_exception_handler(self) + ## API policy implementation methods The following methods are called before dispatching to the handler method. diff --git a/rest_framework/views.py b/rest_framework/views.py index a8710c7a0..92911e8df 100644 --- a/rest_framework/views.py +++ b/rest_framework/views.py @@ -286,6 +286,12 @@ class APIView(View): self._negotiator = self.content_negotiation_class() return self._negotiator + def get_exception_handler(self): + """ + Returns the exception handler that this view uses. + """ + return api_settings.EXCEPTION_HANDLER + # API policy implementation methods def perform_content_negotiation(self, request, force=False): @@ -428,7 +434,7 @@ class APIView(View): else: exc.status_code = status.HTTP_403_FORBIDDEN - exception_handler = self.settings.EXCEPTION_HANDLER + exception_handler = self.get_exception_handler() context = self.get_exception_handler_context() response = exception_handler(exc, context)