The process_exception
only gets invoked when the view raises an Exception
. As it says in the comment:
If the view raised an exception, run it through exception middleware,
and if the exception middleware returns a response, use that.
Otherwise, reraise the exception.
Exceptions raised by misconfiguration, importing error, process_request
and process_view
cannot be caught and feed to process_exception
handlers.
To test whether your process_exception
works, raise an Exception in the view after you ensure it works well.
There is not direct relationship between process_request
and process_exception
. They are handlers for different purposes and get invoked at different stages. Any Exception been raised after the process_request
that executed successfully and before the view, will not be caught and processed by process_exception
as said.