X
X
xxx2018-09-22 22:02:08
Django
xxx, 2018-09-22 22:02:08

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

2 answer(s)
R
Roman Kitaev, 2018-09-22
@deliro

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

E
Eugene Pedya, 2018-09-23
@fpinger

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 question

Ask a Question

731 491 924 answers to any question