mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-01-23 15:54:16 +03:00
Add get_exception_handler_context()
This commit is contained in:
parent
89e9fc98d6
commit
26c223a34f
|
@ -186,6 +186,18 @@ class APIView(View):
|
||||||
'request': getattr(self, 'request', None)
|
'request': getattr(self, 'request', None)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_exception_handler_context(self):
|
||||||
|
"""
|
||||||
|
Returns a dict that is passed through to EXCEPTION_HANDLER,
|
||||||
|
as the `context` argument.
|
||||||
|
"""
|
||||||
|
return {
|
||||||
|
'view': self,
|
||||||
|
'args': getattr(self, 'args', ()),
|
||||||
|
'kwargs': getattr(self, 'kwargs', {}),
|
||||||
|
'request': getattr(self, 'request', None)
|
||||||
|
}
|
||||||
|
|
||||||
def get_view_name(self):
|
def get_view_name(self):
|
||||||
"""
|
"""
|
||||||
Return the view name, as used in OPTIONS responses and in the
|
Return the view name, as used in OPTIONS responses and in the
|
||||||
|
@ -381,7 +393,7 @@ class APIView(View):
|
||||||
)
|
)
|
||||||
response = exception_handler(exc)
|
response = exception_handler(exc)
|
||||||
else:
|
else:
|
||||||
context = self.get_renderer_context()
|
context = self.get_exception_handler_context()
|
||||||
response = exception_handler(exc, context)
|
response = exception_handler(exc, context)
|
||||||
|
|
||||||
if response is None:
|
if response is None:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user