Django Middleware
· β 4 min read
1. __init__(self) In a middleware class, the __init__() method is used to perform system-wide initialization settings.
For performance reasons, each enabled middleware is initialized only once per server process. That is, __init__() is called only when the server process starts, and is not executed while handling an individual request.
For a middleware, the usual reason to define an __init__() method is to check whether it is needed at all.