How to Run Django on Jupyter Notebook Visual Code

27 sec read

previously I have struggled to debug my app when running Python app directly; I need it to run on my Jupyter Workspace easily to debug

this setup successfully load my Django app

create django_initializer.py base project

import sys, os, django

# Find the project base directory
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, BASE_DIR)
# The DJANGO_SETTINGS_MODULE has to be set to allow us to access django imports
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "www.settings")
#  Allow queryset filtering asynchronously when running in a Jupyter notebook
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
# This is for setting up django
django.setup()

then load from jupyter notebook

import django_initializer

from slackevents.models import SnoozeIncidentsReminder

snoozes = SnoozeIncidentsReminder.objects.all()

Multiple Database in Django

how to combine multiple database in django router/db_routers.py settings.py Command Migration Calling Object Database
admin
2 min read

How to secure important data with environments in Python

python file .env
admin
19 sec read

How to secure important data with environments in Django

settings.py .Env
admin
20 sec read

Leave a Reply

Your email address will not be published. Required fields are marked *