Chapter 15. Middleware
On occasion, you'll need to run a piece of code on each and every request that Django handles. This code might need to modify the request before the view handles it, it might need to log information about the request for debugging purposes, and so forth.
You can do this with Django's middleware framework, which is a set of hooks into Django's request/response processing. It's a light, low-level "plug-in" system capable of globally altering both Django's input and output.
Each middleware component is responsible for doing some specific function. If you're reading this book linearly (sorry, postmodernists), you've seen middleware a number of times already:
All of the session and user tools that we looked at in Chapter 12 are ...
Get The Definitive Guide to Django: Web Development Done Right now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.