Using Django in Jupyter Notebook
To explore your Django models in Jupyter Notebook, you can use the following setup.
- Install
django-extensions
pip install django-extensions
- Include
django-extensions
in your settings
INSTALLED_APPS += ['django_extensions']
- Start Django server
python manage.py shell_plus --notebook
- Then, I usually add
DJANGO_ALLOW_ASYNC_UNSAFE
to debug locally. Not recommended on production databases.
import os
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
- Now import your django models
from app.models import User
for user in User.objects.all():
print(user)
10. Mar 2021