Index: django/conf/__init__.py
===================================================================
--- django/conf/__init__.py	(revision 7574)
+++ django/conf/__init__.py	(working copy)
@@ -9,6 +9,7 @@
 import os
 import time     # Needed for Windows
 from django.conf import global_settings
+from django.core.exceptions import wrap_and_raise
 
 ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
 
@@ -84,7 +85,7 @@
         try:
             mod = __import__(self.SETTINGS_MODULE, {}, {}, [''])
         except ImportError, e:
-            raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
+            wrap_and_raise(ImportError("Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)))
 
         # Settings that should be converted into tuples if they're mistakenly entered
         # as strings.
Index: django/core/urlresolvers.py
===================================================================
--- django/core/urlresolvers.py	(revision 7574)
+++ django/core/urlresolvers.py	(working copy)
@@ -8,7 +8,7 @@
 """
 
 from django.http import Http404
-from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
+from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist, wrap_and_raise
 from django.utils.encoding import iri_to_uri, force_unicode, smart_str
 from django.utils.functional import memoize
 import re
@@ -178,7 +178,7 @@
             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))
+            wrap_and_raise(ViewDoesNotExist("Could not import %s. Error was: %s" % (mod_name, str(e))))
         except 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))
@@ -252,7 +252,7 @@
             except Exception, e:
                 # Either an invalid urlconf_name, such as "foo.bar.", or some
                 # kind of problem during the actual import.
-                raise ImproperlyConfigured, "Error while importing URLconf %r: %s" % (self.urlconf_name, e)
+                wrap_and_raise(ImproperlyConfigured("Error while importing URLconf %r: %s" % (self.urlconf_name, e)))
             return self._urlconf_module
     urlconf_module = property(_get_urlconf_module)
 
@@ -266,7 +266,7 @@
         try:
             return getattr(__import__(mod_name, {}, {}, ['']), func_name), {}
         except (ImportError, AttributeError), e:
-            raise ViewDoesNotExist, "Tried %s. Error was: %s" % (callback, str(e))
+            wrap_and_raise(ViewDoesNotExist("Tried %s. Error was: %s" % (callback, str(e))))
 
     def resolve404(self):
         return self._resolve_special('404')
Index: django/core/handlers/base.py
===================================================================
--- django/core/handlers/base.py	(revision 7574)
+++ django/core/handlers/base.py	(working copy)
@@ -2,6 +2,7 @@
 
 from django import http
 from django.core import signals
+from django.core.exceptions import wrap_and_raise
 from django.dispatch import dispatcher
 
 class BaseHandler(object):
@@ -33,7 +34,7 @@
             try:
                 mod = __import__(mw_module, {}, {}, [''])
             except ImportError, e:
-                raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e)
+                wrap_and_raise(exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e)))
             try:
                 mw_class = getattr(mod, mw_classname)
             except AttributeError:
Index: django/core/exceptions.py
===================================================================
--- django/core/exceptions.py	(revision 7574)
+++ django/core/exceptions.py	(working copy)
@@ -32,3 +32,18 @@
     """Some kind of problem with a model field."""
     pass
 
+
+def wrap_and_raise(new_exception):
+    """
+    Call from an except: block to raise a new exception, while keeping
+    the traceback info from the source exception.
+    
+    new_exception is be the Exception (or subclass) instance to raise.
+    """
+    import sys
+    exc_class, exc, tb = sys.exc_info()
+
+    if issubclass(exc_class, Exception):
+        raise new_exception.__class__, new_exception, tb
+    else:
+        raise new_exception
Index: django/contrib/auth/__init__.py
===================================================================
--- django/contrib/auth/__init__.py	(revision 7574)
+++ django/contrib/auth/__init__.py	(working copy)
@@ -1,5 +1,5 @@
 import datetime
-from django.core.exceptions import ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured, wrap_and_raise
 
 SESSION_KEY = '_auth_user_id'
 BACKEND_SESSION_KEY = '_auth_user_backend'
@@ -11,7 +11,7 @@
     try:
         mod = __import__(module, {}, {}, [attr])
     except ImportError, e:
-        raise ImproperlyConfigured, 'Error importing authentication backend %s: "%s"' % (module, e)
+        wrap_and_raise(ImproperlyConfigured('Error importing authentication backend %s: "%s"' % (module, e)))
     except ValueError, e:
         raise ImproperlyConfigured, 'Error importing authentication backends. Is AUTHENTICATION_BACKENDS a correctly defined list or tuple?'
     try:
Index: django/template/__init__.py
===================================================================
--- django/template/__init__.py	(revision 7574)
+++ django/template/__init__.py	(working copy)
@@ -51,6 +51,7 @@
 import re
 from inspect import getargspec
 from django.conf import settings
+from django.core.exceptions import wrap_and_raise
 from django.template.context import Context, RequestContext, ContextPopException
 from django.utils.itercompat import is_iterable
 from django.utils.functional import curry, Promise
@@ -919,7 +920,7 @@
         try:
             mod = __import__(module_name, {}, {}, [''])
         except ImportError, e:
-            raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e))
+            wrap_and_raise(InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e)))
         try:
             lib = mod.register
             libraries[module_name] = lib
Index: django/template/loaders/app_directories.py
===================================================================
--- django/template/loaders/app_directories.py	(revision 7574)
+++ django/template/loaders/app_directories.py	(working copy)
@@ -6,7 +6,7 @@
 import os
 
 from django.conf import settings
-from django.core.exceptions import ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured, wrap_and_raise
 from django.template import TemplateDoesNotExist
 from django.utils._os import safe_join
 
@@ -24,7 +24,7 @@
         else:
             mod = getattr(__import__(m, {}, {}, [a]), a)
     except ImportError, e:
-        raise ImproperlyConfigured, 'ImportError %s: %s' % (app, e.args[0])
+        wrap_and_raise(ImproperlyConfigured('ImportError %s: %s' % (app, e.args[0])))
     template_dir = os.path.join(os.path.dirname(mod.__file__), 'templates')
     if os.path.isdir(template_dir):
         app_template_dirs.append(template_dir)
Index: django/template/defaulttags.py
===================================================================
--- django/template/defaulttags.py	(revision 7574)
+++ django/template/defaulttags.py	(working copy)
@@ -12,6 +12,7 @@
 from django.template import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END
 from django.template import get_library, Library, InvalidTemplateLibrary
 from django.conf import settings
+from django.core.exceptions import wrap_and_raise
 from django.utils.encoding import smart_str, smart_unicode
 from django.utils.itercompat import groupby
 from django.utils.safestring import mark_safe
@@ -853,8 +854,8 @@
             lib = get_library("django.templatetags.%s" % taglib)
             parser.add_library(lib)
         except InvalidTemplateLibrary, e:
-            raise TemplateSyntaxError("'%s' is not a valid tag library: %s" %
-                                      (taglib, e))
+            wrap_and_raise(TemplateSyntaxError("'%s' is not a valid tag library: %s" %
+                                      (taglib, e)))
     return LoadNode()
 load = register.tag(load)
 
Index: django/template/context.py
===================================================================
--- django/template/context.py	(revision 7574)
+++ django/template/context.py	(working copy)
@@ -1,5 +1,5 @@
 from django.conf import settings
-from django.core.exceptions import ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured, wrap_and_raise
 
 _standard_context_processors = None
 
@@ -77,7 +77,7 @@
             try:
                 mod = __import__(module, {}, {}, [attr])
             except ImportError, e:
-                raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))
+                wrap_and_raise(ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e)))
             try:
                 func = getattr(mod, attr)
             except AttributeError:
Index: django/template/loader.py
===================================================================
--- django/template/loader.py	(revision 7574)
+++ django/template/loader.py	(working copy)
@@ -20,7 +20,7 @@
 # Python eggs) sets is_usable to False if the "pkg_resources" module isn't
 # installed, because pkg_resources is necessary to read eggs.
 
-from django.core.exceptions import ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured, wrap_and_raise
 from django.template import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins
 from django.conf import settings
 
@@ -53,7 +53,7 @@
             try:
                 mod = __import__(module, globals(), locals(), [attr])
             except ImportError, e:
-                raise ImproperlyConfigured, 'Error importing template source loader %s: "%s"' % (module, e)
+                wrap_and_raise(ImproperlyConfigured('Error importing template source loader %s: "%s"' % (module, e)))
             try:
                 func = getattr(mod, attr)
             except AttributeError:
