process_request methods called?Django calls process_request methods in the order middleware are listed in settings. So M1 first, then M2, then M3.
process_response methods called when returning a response?Django calls process_response methods in reverse order of the middleware list. So M3 first, then M2, then M1.
process_request returns an HttpResponse object instead of None, what happens next?If a middleware's process_request returns a response, Django skips calling later middleware's process_request and the view. It starts calling process_response in reverse order from the middleware that returned the response.
process_view method?The process_view method receives the request, the view function, and the positional and keyword arguments for the view.
process_response modifies the response content. But you notice M2's process_response changes overwrite M3's changes. Why?process_response methods run in reverse order of middleware list. So M3 runs before M2. M2's changes overwrite M3's if both modify the same response parts.
