diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py index b5cdccb730..b537633646 100644 --- a/django/core/urlresolvers.py +++ b/django/core/urlresolvers.py @@ -38,8 +38,10 @@ class RegexURLPattern: mod_name, func_name = get_mod_func(self.callback) try: return getattr(__import__(mod_name, '', '', ['']), func_name) - except (ImportError, AttributeError), e: - raise ViewDoesNotExist, "Tried %s. Error was: %s" % (self.callback, str(e)) + except ImportError, e: + raise ViewDoesNotExist, "Could not import %s. Error was: %s" % (mod_name, str(e)) + except AttributeError, e: + raise ViewDoesNotExist, "Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)) class RegexURLMultiplePattern: def __init__(self, regex, urlconf_module):