more informations to the views or templates • Altering the data inside a request before it reaches the views/templates • Having a different behaviour in the views/templates, depending on certain conditions (ignoring requests from a particular IP address)
need to write a class that just inherits from object • The order in settings.py is important: middlewares are processed from top to bottom during a request and from bottom to top during a response. • You don’t need to implement all the available methods of a middleware. For example you can just implement process_request and process_template_response • If you implement process_request and you decide to return an HttpResponse, all the other middlewares, views etc… will be ignored and only your response will be returned