Skip to content

Commit bbb4635

Browse files
committed
fix: add missing middlewares and context processor
prior to this change only `MIDDLEWARE_CLASSES` was defined, and the tuple was overridden, effectively excluding `SessionMiddleware` and `AuthenticationMiddleware`. In addittion, Django's built-in `messages` context processor is required for enalbing admin in our test project.
1 parent efc5166 commit bbb4635

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tests/settings.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def local_path(path):
1919

2020
INSTALLED_APPS = [
2121
'django.contrib.contenttypes',
22+
'django.contrib.messages',
2223
'django.contrib.sites',
2324
'django.contrib.sessions',
2425
'django.contrib.staticfiles',
@@ -28,16 +29,15 @@ def local_path(path):
2829
'tests.tests'
2930
]
3031

31-
MIDDLEWARE_CLASSES = (
32-
'django.contrib.sessions.middleware.SessionMiddleware',
33-
'django.contrib.auth.middleware.AuthenticationMiddleware'
34-
)
3532

3633
ROOT_URLCONF = 'tests.urls'
3734

38-
MIDDLEWARE_CLASSES = (
35+
MIDDLEWARE = MIDDLEWARE_CLASSES = (
36+
'django.contrib.sessions.middleware.SessionMiddleware',
37+
'django.contrib.auth.middleware.AuthenticationMiddleware',
38+
'django.contrib.messages.middleware.MessageMiddleware',
3939
'django.middleware.common.CommonMiddleware',
40-
'django.middleware.csrf.CsrfViewMiddleware'
40+
'django.middleware.csrf.CsrfViewMiddleware',
4141
)
4242

4343
MEDIA_URL = '/media/'
@@ -172,6 +172,7 @@ def node_exe_path(command):
172172
'OPTIONS': {
173173
'context_processors': [
174174
'django.contrib.auth.context_processors.auth',
175+
'django.contrib.messages.context_processors.messages',
175176
]
176177
}
177178
},

0 commit comments

Comments
 (0)