From 18759b2209ff556aed7f20d83cbf23e3d234e41c Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Mon, 25 May 2020 16:41:24 +0200 Subject: [PATCH] Fixed #31616 -- Added hint about middleware ordering for SessionMiddleware admin check. --- django/contrib/admin/checks.py | 6 ++++++ tests/admin_checks/tests.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py index 5e4b785c33..a18ba22b46 100644 --- a/django/contrib/admin/checks.py +++ b/django/contrib/admin/checks.py @@ -132,6 +132,12 @@ def check_dependencies(**kwargs): errors.append(checks.Error( "'django.contrib.sessions.middleware.SessionMiddleware' must " "be in MIDDLEWARE in order to use the admin application.", + hint=( + "Insert " + "'django.contrib.sessions.middleware.SessionMiddleware' " + "before " + "'django.contrib.auth.middleware.AuthenticationMiddleware'." + ), id='admin.E410', )) return errors diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py index 52f2188c9f..5744dc1b39 100644 --- a/tests/admin_checks/tests.py +++ b/tests/admin_checks/tests.py @@ -214,6 +214,12 @@ class SystemChecksTestCase(SimpleTestCase): checks.Error( "'django.contrib.sessions.middleware.SessionMiddleware' " "must be in MIDDLEWARE in order to use the admin application.", + hint=( + "Insert " + "'django.contrib.sessions.middleware.SessionMiddleware' " + "before " + "'django.contrib.auth.middleware.AuthenticationMiddleware'." + ), id='admin.E410', ), ]