Install django-extensions
pip install django-extensions
Change your settings file to include ‘django-extensions’
INSTALLED_APPS += ['django_extensions']
Run your Django server like this:
python manage.py shell_plus --notebook
Remote Access
On the local machine, start an SSH tunnel to access Jupyter:
local_user@local_host$ ssh -N -f -L localhost:8888:localhost:8888 remote_user@remote_host
In the browser, start a new “Django Shell-Plus”
Open “Django Shell-Plus”
alter to suit, and run this in your first cell
MYPROJECT = '/home/john/work/myproject'
import os, sys
sys.path.insert(0, MYPROJECT)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "local_settings.py")
import django
django.setup()
Now you should be able to import your django models etc. eg:
from app.models import Foobar
Foobar.objects.all()