diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py index ba2e286721..c34d0b52cb 100644 --- a/django/core/handlers/base.py +++ b/django/core/handlers/base.py @@ -17,7 +17,10 @@ class BaseHandler: self._response_middleware = [] self._exception_middleware = [] for middleware_path in settings.MIDDLEWARE_CLASSES: - dot = middleware_path.rindex('.') + try: + dot = middleware_path.rindex('.') + except ValueError: + raise exceptions.ImproperlyConfigured, '%s isn\'t look like a middleware module' % middleware_path mw_module, mw_classname = middleware_path[:dot], middleware_path[dot+1:] try: mod = __import__(mw_module, '', '', [''])