custom exception handler for DRF response and Djan

2019-08-27 14:17发布

I'd like to define a custom exception class and raise it.

Django rest framework has a hook where I can define custom exception handler,

(http://www.django-rest-framework.org/api-guide/exceptions/#custom-exception-handling)

Django also provides a way to do it via middleware.

Question: If I want to handle exceptions in drf views and regular django views, would it be sufficient to handle them in django middleware?

Or do I need separate handler for DRF views?

In other words, does DRF request/response goes through django middleware as well or not?

0条回答
登录 后发表回答