Index: django/conf/global_settings.py
===================================================================
--- django/conf/global_settings.py	(revision 15477)
+++ django/conf/global_settings.py	(working copy)
@@ -583,3 +583,11 @@
 # Make sure to use a trailing slash.
 # Examples: "http://foo.com/static/admin/", "/static/admin/".
 ADMIN_MEDIA_PREFIX = '/static/admin/'
+
+# Run ipython or python interactive shell when
+# an uncaught exception occure, if set to "interactive"
+# run pdb debugger when an uncaught exception raised,
+# if set to "pdb"
+# any other value is not valid
+
+INLINE_DEBUGGER = None
Index: django/core/handlers/base.py
===================================================================
--- django/core/handlers/base.py	(revision 15477)
+++ django/core/handlers/base.py	(working copy)
@@ -9,6 +9,10 @@
 logger = getLogger('django.request')
 
 
+class WrongValue (Exception):
+    pass
+
+
 class BaseHandler(object):
     # Changes that are always applied to a response (in this order).
     response_fixes = [
@@ -199,6 +203,45 @@
             raise
 
         if settings.DEBUG:
+            # Run an interactive shell or pdb when an uncaught exception
+            # raised. if INLINE_DEBUGGER defined.
+            if not exc_info[0] == SyntaxError:
+                if settings.INLINE_DEBUGGER:
+                    if settings.INLINE_DEBUGGER == "interactive":
+                        tbtmp = exc_info[-1]
+                        tb = None
+                        while tbtmp:
+                            tbtmp = tbtmp.tb_next
+                            if tbtmp is not None:
+                                tb = tbtmp
+                        import traceback
+                        print
+                        traceback.print_exception(*exc_info)
+
+                        try:
+                            from IPython import Shell
+                            ipshell = Shell.start()
+                            ipshell.IP.api.to_user_ns(tb.tb_frame.f_locals)
+                            ipshell.IP.api.to_user_ns(tb.tb_frame.f_globals)
+                            ipshell.mainloop()
+
+                        except ImportError:
+                            import code
+                            shell = code.InteractiveConsole(tb.tb_frame.f_locals)
+                            shell.interact()
+
+                    elif settings.INLINE_DEBUGGER == "pdb":
+                        import pdb
+                        import traceback
+                        print
+                        traceback.print_exception(*exc_info)
+                        pdb.post_mortem(exc_info[-1])
+                    else:
+                        exception = WrongValue("'%s'is invalid value for'setting.INLINE_DEBUGGER'. Use 'pdb' or 'interactive' instead." % \
+                                               settings.INLINE_DEBUGGER)
+                        exc_info = (type(exception), exception, None)
+
+
             from django.views import debug
             return debug.technical_500_response(request, *exc_info)
 
