Index: django/core/urlresolvers.py
===================================================================
--- django/core/urlresolvers.py	(revision 15395)
+++ django/core/urlresolvers.py	(working copy)
@@ -162,12 +162,18 @@
             return self._callback
         try:
             self._callback = get_callable(self._callback_str)
-        except ImportError, e:
-            mod_name, _ = get_mod_func(self._callback_str)
-            raise ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e)))
-        except AttributeError, e:
+        except (ImportError, AttributeError), e:
             mod_name, func_name = get_mod_func(self._callback_str)
-            raise ViewDoesNotExist("Tried %s in module %s. Error was: %s" % (func_name, mod_name, str(e)))
+            debug_info = ''
+            if settings.DEBUG:
+                if hasattr(self, '_origin_line'): # extra debug info available
+                    debug_info = ' from line "%s" at %s:%s' % self._origin_line
+                elif hasattr(self, '_origin_module'):
+                    debug_info = ' from pattern "%s" in %s' % ((self.regex.pattern,) + self._origin_module)
+            if isinstance(e, ImportError):
+                raise ViewDoesNotExist("Could not import %s%s. Error was: %s" % (mod_name, debug_info, str(e)))
+            elif isinstance(e, AttributeError):
+                raise ViewDoesNotExist("Tried %s in module %s%s. Error was: %s" % (func_name, mod_name, debug_info, str(e)))
         return self._callback
     callback = property(_get_callback)
 
Index: django/conf/urls/defaults.py
===================================================================
--- django/conf/urls/defaults.py	(revision 15395)
+++ django/conf/urls/defaults.py	(working copy)
@@ -1,3 +1,4 @@
+from django.conf import settings
 from django.core.urlresolvers import RegexURLPattern, RegexURLResolver
 from django.core.exceptions import ImproperlyConfigured
 
@@ -17,6 +18,22 @@
         urlconf_module = arg
     return (urlconf_module, app_name, namespace)
 
+def _get_pattern_origin(urlobj):
+    """ Finds out which module called this pattern/url for debug purposes. """
+    import inspect
+    import os.path
+    current_frame = inspect.currentframe()
+    if current_frame: # currentframe not always supported
+        calling_frames = inspect.getouterframes(current_frame)
+        index = 0
+        while calling_frames[index][3] != '<module>': # find the module
+            index = index + 1
+        calling_frame = calling_frames[index]
+        if index == 2: # direct call from url(), get line details
+            urlobj._origin_line = (calling_frame[4], os.path.normpath(calling_frame[1]), calling_frame[2], )
+        else: # url() created by patterns(), only show module
+            urlobj._origin_module = (os.path.normpath(calling_frame[1]), ) 
+
 def patterns(prefix, *args):
     pattern_list = []
     for t in args:
@@ -31,12 +48,16 @@
     if isinstance(view, (list,tuple)):
         # For include(...) processing.
         urlconf_module, app_name, namespace = view
-        return RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace)
+        urlobj = RegexURLResolver(regex, urlconf_module, kwargs, app_name=app_name, namespace=namespace)
     else:
         if isinstance(view, basestring):
             if not view:
                 raise ImproperlyConfigured('Empty URL pattern view name not permitted (for pattern %r)' % regex)
             if prefix:
                 view = prefix + '.' + view
-        return RegexURLPattern(regex, view, kwargs, name)
+        urlobj = RegexURLPattern(regex, view, kwargs, name)
 
+    if settings.DEBUG: # attach debug information to object
+        _get_pattern_origin(urlobj)
+    return urlobj
+
Index: tests/regressiontests/urlpatterns_errors/__init__.py
===================================================================
Index: tests/regressiontests/urlpatterns_errors/models.py
===================================================================
Index: tests/regressiontests/urlpatterns_errors/tests.py
===================================================================
--- tests/regressiontests/urlpatterns_errors/tests.py	(revision 0)
+++ tests/regressiontests/urlpatterns_errors/tests.py	(revision 0)
@@ -0,0 +1,83 @@
+from django.conf import settings
+from django.core.urlresolvers import RegexURLResolver, ViewDoesNotExist
+from django.test import TestCase
+
+class URLPatternErrorsTestsNonSpecific(TestCase):
+    urls = 'regressiontests.urlpatterns_errors.urls'
+
+    def assertRaisesErrorWithStart(self, error, message, callable,
+        *args, **kwargs):
+        self.assertRaises(error, callable, *args, **kwargs)
+        try:
+            callable(*args, **kwargs)
+        except error, e: # check start of message only
+            self.assertEqual(message, str(e)[:len(message)])
+
+    def test_resolve_errors_nonspecific(self):
+        """
+        Resolver should raise exceptions pointing only divulging
+        basic information
+        """
+        
+        olddebug = settings.DEBUG
+        settings.DEBUG = False
+
+        resolver = RegexURLResolver(r'^', self.urls)
+
+        # Import errors
+        self.assertRaisesErrorWithStart(ViewDoesNotExist, 
+            "Could not import nonexistent. Error was:", resolver.resolve, 
+            'first-urled/')
+        self.assertRaisesErrorWithStart(ViewDoesNotExist, 
+            "Could not import nonexistent. Error was:", resolver.resolve, 
+            'second-nonurled/')
+
+        # Attribute errors
+        self.assertRaisesErrorWithStart(ViewDoesNotExist, 
+            "Tried nonexistent in module regressiontests.urlpatterns_errors.views.", 
+            resolver.resolve, 'third-urled/')
+        self.assertRaisesErrorWithStart(ViewDoesNotExist, 
+            "Tried nonexistent in module regressiontests.urlpatterns_errors.views.",
+            resolver.resolve, 'fourth-nonurled/')
+
+        settings.DEBUG = olddebug
+
+class URLPatternErrorsSpecificTests(TestCase):
+    urls = 'regressiontests.urlpatterns_errors.urls'
+
+    def assertRaisesErrorWithStart(self, error, message, callable,
+        *args, **kwargs):
+        self.assertRaises(error, callable, *args, **kwargs)
+        try:
+            callable(*args, **kwargs)
+        except error, e: # check start of message only
+            self.assertEqual(message, str(e)[:len(message)])
+
+    def test_resolve_errors_specific(self):
+        """
+        Resolver should raise exceptions pointing to the urls module
+        if that information is available
+        """
+        
+        olddebug = settings.DEBUG
+        settings.DEBUG = True
+
+        resolver = RegexURLResolver(r'^', self.urls)
+
+        # Import errors
+        self.assertRaisesErrorWithStart(ViewDoesNotExist, 
+            "Could not import nonexistent from line", resolver.resolve, 
+            'first-urled/')
+        self.assertRaisesErrorWithStart(ViewDoesNotExist, 
+            "Could not import nonexistent from pattern", resolver.resolve, 
+            'second-nonurled/')
+
+        # Attribute errors
+        self.assertRaisesErrorWithStart(ViewDoesNotExist, 
+            "Tried nonexistent in module regressiontests.urlpatterns_errors.views from line", 
+            resolver.resolve, 'third-urled/')
+        self.assertRaisesErrorWithStart(ViewDoesNotExist, 
+            "Tried nonexistent in module regressiontests.urlpatterns_errors.views from pattern",
+            resolver.resolve, 'fourth-nonurled/')
+
+        settings.DEBUG = olddebug
Index: tests/regressiontests/urlpatterns_errors/urls.py
===================================================================
--- tests/regressiontests/urlpatterns_errors/urls.py	(revision 0)
+++ tests/regressiontests/urlpatterns_errors/urls.py	(revision 0)
@@ -0,0 +1,8 @@
+from django.conf.urls.defaults import url, patterns
+
+urlpatterns = patterns('', 
+    url(r'^first-urled/$', 'nonexistent.view'),
+    (r'^second-nonurled/$', 'nonexistent.view'),
+    url(r'^third-urled/$', 'regressiontests.urlpatterns_errors.views.nonexistent'),
+    (r'^fourth-nonurled/$', 'regressiontests.urlpatterns_errors.views.nonexistent'),
+)
Index: tests/regressiontests/urlpatterns_errors/views.py
===================================================================
