Commits

Anonymous committed 76f334a

[1.2.X] Fixed #12735 and #14892 -- Fixed support for the latest IPython (development) version in the shell management command.

Backport from trunk (r14895).

  • Participants
  • Parent commits 7ad0d20
  • Branches releases/1.2.X

Comments (0)

Files changed (1)

django/core/management/commands/shell.py

             if use_plain:
                 # Don't bother loading IPython, because the user wants plain Python.
                 raise ImportError
-            import IPython
-            # Explicitly pass an empty list as arguments, because otherwise IPython
-            # would use sys.argv from this script.
-            shell = IPython.Shell.IPShell(argv=[])
-            shell.mainloop()
+            try:
+                from IPython.frontend.terminal.embed import TerminalInteractiveShell
+                shell = TerminalInteractiveShell()
+                shell.mainloop()
+            except ImportError:
+                # IPython < 0.11
+                # Explicitly pass an empty list as arguments, because otherwise
+                # IPython would use sys.argv from this script.
+                try:
+                    from IPython.Shell import IPShell
+                    shell = IPShell(argv=[])
+                    shell.mainloop()
+                except ImportError:
+                    # IPython not found at all, raise ImportError
+                    raise
         except ImportError:
             import code
             # Set up a dictionary to serve as the environment for the shell, so