diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index b34d0e096e..3f3bf44075 100644 --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -24,10 +24,11 @@ class BaseHandler(object): """ from django.conf import settings from django.core import exceptions - self._request_middleware = [] self._view_middleware = [] self._response_middleware = [] self._exception_middleware = [] + + request_middleware = [] for middleware_path in settings.MIDDLEWARE_CLASSES: try: dot = middleware_path.rindex('.') @@ -57,6 +58,10 @@ class BaseHandler(object): if hasattr(mw_instance, 'process_exception'): self._exception_middleware.insert(0, mw_instance.process_exception) + # We only assign to this when initialization is complete as it is used + # as a flag for initialization being complete. + self._request_middleware = request_middleware + def get_response(self, request): "Returns an HttpResponse object for the given HttpRequest" from django.core import exceptions, urlresolvers