Skip to content

Instantly share code, notes, and snippets.

@jjorissen52
Created September 25, 2020 17:50
Show Gist options
  • Save jjorissen52/f41a0df9d1f6ac11443faa70e14234a7 to your computer and use it in GitHub Desktop.
Save jjorissen52/f41a0df9d1f6ac11443faa70e14234a7 to your computer and use it in GitHub Desktop.
Import Django in Script or Jupyter Notebook
import os
import dotenv
dotenv.read_dotenv(override=True)
os.environ["DJANGO_ALLOW_ASYNC_UNSAFE"] = "true"
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_project.settings")
# django.setup() is called as a side-effect
from django.core.wsgi import get_wsgi_application
_ = get_wsgi_application()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment