summaryrefslogtreecommitdiff
path: root/django/utils/deprecation.py
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2019-09-26 19:06:35 +0200
committerCarlton Gibson <carlton@noumenal.es>2020-02-18 20:03:44 +0100
commit4d973f593932285cd2f765400d915305d8e7333a (patch)
tree1cc48fd9e979d77906e522ecad2689d156d1377f /django/utils/deprecation.py
parenta34cb5a6d408203f4fbdb364fc9768c026eda224 (diff)
Refs #26601 -- Deprecated passing None as get_response arg to middleware classes.
This is the new contract since middleware refactoring in Django 1.10. Co-authored-by: Carlton Gibson <carlton.gibson@noumenal.es> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'django/utils/deprecation.py')
-rw-r--r--django/utils/deprecation.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/django/utils/deprecation.py b/django/utils/deprecation.py
index 6599cd2e83..81e7c3a15b 100644
--- a/django/utils/deprecation.py
+++ b/django/utils/deprecation.py
@@ -80,7 +80,10 @@ class DeprecationInstanceCheck(type):
class MiddlewareMixin:
+ # RemovedInDjango40Warning: when the deprecation ends, replace with:
+ # def __init__(self, get_response):
def __init__(self, get_response=None):
+ self._get_response_none_deprecation(get_response)
self.get_response = get_response
super().__init__()
@@ -92,3 +95,11 @@ class MiddlewareMixin:
if hasattr(self, 'process_response'):
response = self.process_response(request, response)
return response
+
+ def _get_response_none_deprecation(self, get_response):
+ if get_response is None:
+ warnings.warn(
+ 'Passing None for the middleware get_response argument is '
+ 'deprecated.',
+ RemovedInDjango40Warning, stacklevel=3,
+ )