Code

Ticket #18204: embed-ipython-module.diff

File embed-ipython-module.diff, 647 bytes (added by ogier, 2 years ago)
Line 
1diff --git a/django/core/management/commands/shell.py b/django/core/management/commands/shell.py
2index 26cbd7f..3c2b8e9 100644
3--- a/django/core/management/commands/shell.py
4+++ b/django/core/management/commands/shell.py
5@@ -13,8 +13,8 @@ class Command(NoArgsCommand):
6 
7     def ipython(self):
8         try:
9-            from IPython import embed
10-            embed()
11+            # embed() needs to run in its own global context. See #18204
12+            exec "from IPython import embed; embed()" in globals()
13         except ImportError:
14             # IPython < 0.11
15             # Explicitly pass an empty list as arguments, because otherwise