Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
ebe174c0
Commit
ebe174c0
authored
Dec 15, 2016
by
Eduard Iskandarov
Committed by
Tom Christie
Dec 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add per-view custom exception handler support (#4753)
parent
ecb90526
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletions
+9
-1
docs/api-guide/views.md
+2
-0
rest_framework/views.py
+7
-1
No files found.
docs/api-guide/views.md
View file @
ebe174c0
...
...
@@ -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.
...
...
rest_framework/views.py
View file @
ebe174c0
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment