Answer the question
In order to leave comments, you need to log in
What typical tasks are solved through the django middleware?
I'm studying middleware, I wrote a count of visits through middleware, but I'm tormented by the question - What typical tasks are solved with the help of an intermediate layer? I can assume that these are various actions on the request arguments and so on, until I ran into some kind of problem that needs to be solved specifically through the middleware. If you can, describe the problems you solved through this mechanism.
Answer the question
In order to leave comments, you need to log in
1. User identification. For example, custom authentication or setting some permanent cookies
2. Sessions
3. Logging responses/requests
4. Restricting access to multiple URLs with a certain prefix
5. Injection into an HTML response
What we managed to come up with in a minute
The middleway does what needs to be done for multiple routes. Thus, we get rid of code duplication.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question