The order of middleware affections the outcome. Some middleware are dependant on the functionality of other middleware. For example a middleware that requires usage of request.session should come after the SessionMiddleware.

If our GitHub code review bot spots this issue in your pull request it gives this advice:

django-doctorbotsuggested changes just now
settings.py
1
+
MIDDLEWARE =[
2
+
    "django.contrib.auth.middleware.AuthenticationMiddleware",
3
+
    "django.contrib.sessions.middleware.SessionMiddleware",

The order of middleware affections the outcome. Some middleware are dependant on the functionality of other middleware. For example a middleware that requires usage of request.session should come after the SessionMiddleware.

Read more
4
+
    ...
5
+
]
Update settings.py

Instantly check if you have this issue for free

    Works with tools you use

    Read about how it works.