Skip to content

Latest commit

 

History

History
10 lines (9 loc) · 690 Bytes

Jupyter_django_shell.md

File metadata and controls

10 lines (9 loc) · 690 Bytes

How to use the Django shell in Jupyter Notebook?

  • pip install django jupyter ipython django-extensions
  • INSTALLED_APPS = [ ... 'django_extensions', ]
  • python manage.py shell_plus --notebook

After opening Jupter Notebook type import os os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"

** IMPORTANT! IPython added top-level async/await support, which is running the whole interpreter session inside of a default event loop and starting from Django 3.0 version running application from a thread where there is a running event loop, will cause a SynchronousOnlyOperation error. So, setting DJANGO_ALLOW_ASYNC_UNSAFE to true is mandatory in that case. More on this here. **