Introduction
Middleware helps Django handle tasks before and after a web request. It makes your app smarter and easier to manage.
You want to check if a user is logged in before showing a page.
You need to add special headers to every response from your site.
You want to log details about each visitor automatically.
You want to block bad users or bots from accessing your site.
You want to modify requests or responses without changing your main code.