=== django/utils/shell.py
==================================================================
--- django/utils/shell.py	(revision 2559)
+++ django/utils/shell.py	(local)
@@ -0,0 +1,64 @@
+"""
+Django embedded IPython shell
+
+When using the development server Django's embedded IPython shell allows you to
+drop into a Python shell at any point during a request to inspect the local
+namespace.
+
+Requires IPython.
+
+usage:
+
+from django.utils.shell import ipshell
+
+def some_view(request):
+    response = render_to_response(...)
+    ipshell() # suspend request here and drop into IPython shell
+    return response
+
+If a call to ipshell() is left in production code a warning will be sent to
+stdout and processing will continue normally.
+
+"""
+
+BANNER = """
+# Interrupting this request to bring you the Django Shell!
+
+Django  %s
+Python  %s
+IPython %s
+
+?       -> Introduction to IPython's features.
+%%magic  -> Information about IPython's 'magic' functions.
+help    -> Python's own help system.
+object? -> Details about 'object'. ?object also works, ?? prints more.
+
+Type Ctrl-D or 'quit' to continue serving the request."""
+
+def make_fake_shell(message):
+    def ipshell():
+        print "\n# %s\n" % message
+    return ipshell
+
+try:
+    from IPython.Shell import IPShellEmbed
+except ImportError:
+    ipshell = make_fake_shell("Django Shell error: Could not import IPython")
+else:
+    import django
+    import sys
+    import IPython
+
+    def version_to_string(version_info):
+        return '%s.%s.%s %s' % version_info[:4]
+
+    # Django development server sets a __builtin__ flag so we can check it is running
+    try:
+        __DJANGO_DEVELOPMENT_SERVER__
+    except NameError:
+        ipshell = make_fake_shell("Django Shell warning: ipshell() called from non-development server, ignored")
+    else:
+        ipshell = IPShellEmbed([], banner=BANNER % (
+            version_to_string(django.VERSION),
+            version_to_string(sys.version_info),
+            IPython.__version__))
=== django/core/servers/basehttp.py
==================================================================
--- django/core/servers/basehttp.py	(revision 2559)
+++ django/core/servers/basehttp.py	(local)
@@ -637,6 +637,9 @@
         return output
 
 def run(addr, port, wsgi_handler):
+    # Development server flag checked by django.utils.shell.ipshell()
+    import __builtin__
+    __builtin__.__DJANGO_DEVELOPMENT_SERVER__ = True
     server_address = (addr, port)
     httpd = WSGIServer(server_address, WSGIRequestHandler)
     httpd.set_app(wsgi_handler)
