Incorrectly ordered middleware can stop the middleware working as intended.
The order of middleware affections the outcome.
Some middleware should be near the top of the middleware list to ensure it is one of the first to be called.
For example CommonMiddleware, LocaleMiddleware, and SecurityMiddleware should be near the top.
If our GitHub code review bot spots this issue in your pull request it gives this advice:
1 | + | MIDDLEWARE =[ | |
2 | + | "django.contrib.sessions.middleware.SessionMiddleware", | |
3 | + | "django.contrib.auth.middleware.AuthenticationMiddleware", | |
4 | + | "django.contrib.messages.middleware.MessageMiddleware", | |
5 | + | "django.middleware.common.CommonMiddleware", |
Incorrectly ordered middleware can stop the middleware working as intended.
Read more6 | + | ] |