summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-05-09 19:58:47 -0400
committerTim Graham <timograham@gmail.com>2016-05-13 17:23:58 -0400
commit5e4920c14b2706178474ebbf335eda870dbc8ee8 (patch)
tree97df1a2c724a298385d666c23d82e4d61986f8b7
parent92c069ad334cbe2ff20b27c4dd9920d230a4916b (diff)
downloaddjango-dep5.tar.gz
Refs #26601 -- Added a warning if both MIDDLEWARE AND MIDDLEWARE_CLASSES are set.dep5
-rw-r--r--django/core/checks/__init__.py1
-rw-r--r--django/core/checks/compatibility/django_1_10.py17
-rw-r--r--docs/ref/checks.txt3
-rw-r--r--tests/check_framework/tests_1_10_compatibility.py17
4 files changed, 38 insertions, 0 deletions
diff --git a/django/core/checks/__init__.py b/django/core/checks/__init__.py
index 657d0419f0..4a7479ab2b 100644
--- a/django/core/checks/__init__.py
+++ b/django/core/checks/__init__.py
@@ -10,6 +10,7 @@ from .registry import Tags, register, run_checks, tag_exists
# Import these to force registration of checks
import django.core.checks.caches # NOQA isort:skip
import django.core.checks.compatibility.django_1_8_0 # NOQA isort:skip
+import django.core.checks.compatibility.django_1_10 # NOQA isort:skip
import django.core.checks.database # NOQA isort:skip
import django.core.checks.model_checks # NOQA isort:skip
import django.core.checks.security.base # NOQA isort:skip
diff --git a/django/core/checks/compatibility/django_1_10.py b/django/core/checks/compatibility/django_1_10.py
new file mode 100644
index 0000000000..0ab28df6f8
--- /dev/null
+++ b/django/core/checks/compatibility/django_1_10.py
@@ -0,0 +1,17 @@
+from __future__ import unicode_literals
+
+from django.conf import global_settings, settings
+
+from .. import Tags, Warning, register
+
+
+@register(Tags.compatibility)
+def check_duplicate_middleware_settings(app_configs, **kwargs):
+ if settings.MIDDLEWARE is not None and settings.MIDDLEWARE_CLASSES != global_settings.MIDDLEWARE_CLASSES:
+ return [Warning(
+ "The MIDDLEWARE_CLASSES setting is deprecated in Django 1.10 "
+ "and the MIDDLEWARE setting takes precedence. Since you've set "
+ "MIDDLEWARE, the value of MIDDLEWARE_CLASSES is ignored.",
+ id='1_10.W001',
+ )]
+ return []
diff --git a/docs/ref/checks.txt b/docs/ref/checks.txt
index 5057ef18b6..f852c777ad 100644
--- a/docs/ref/checks.txt
+++ b/docs/ref/checks.txt
@@ -266,6 +266,9 @@ that might occur as a result of a version upgrade.
put the values of the following settings into your defaults ``TEMPLATES``
dict: ``TEMPLATE_DIRS``, ``TEMPLATE_CONTEXT_PROCESSORS``, ``TEMPLATE_DEBUG``,
``TEMPLATE_LOADERS``, ``TEMPLATE_STRING_IF_INVALID``.
+* **1_10.W001**: The ``MIDDLEWARE_CLASSES`` setting is deprecated in Django
+ 1.10 and the :setting:`MIDDLEWARE` setting takes precedence. Since you've
+ set ``MIDDLEWARE``, the value of ``MIDDLEWARE_CLASSES`` is ignored.
Admin
-----
diff --git a/tests/check_framework/tests_1_10_compatibility.py b/tests/check_framework/tests_1_10_compatibility.py
new file mode 100644
index 0000000000..388ac1b024
--- /dev/null
+++ b/tests/check_framework/tests_1_10_compatibility.py
@@ -0,0 +1,17 @@
+from django.core.checks.compatibility.django_1_10 import \
+ check_duplicate_middleware_settings
+from django.test import SimpleTestCase
+from django.test.utils import override_settings
+
+
+class CheckDuplicateMiddlwareSettingsTest(SimpleTestCase):
+
+ @override_settings(MIDDLEWARE=[], MIDDLEWARE_CLASSES=['django.middleware.common.CommonMiddleware'])
+ def test_duplicate_setting(self):
+ result = check_duplicate_middleware_settings(None)
+ self.assertEqual(result[0].id, '1_10.W001')
+
+ @override_settings(MIDDLEWARE=None)
+ def test_middleware_not_defined(self):
+ result = check_duplicate_middleware_settings(None)
+ self.assertEqual(len(result), 0)