Created
November 20, 2012 16:57
-
-
Save chrisdev/4119236 to your computer and use it in GitHub Desktop.
IPython notebook extension for Django project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup_django_env(path): | |
import imp | |
import sys | |
from os.path import join | |
from django.core.management import setup_environ | |
f, filename, desc = imp.find_module('settings', [path]) | |
project = imp.load_module('settings', f, filename, desc) | |
setup_environ(project) | |
sys.path.insert(0, PATH_TO_DJANGO_PROJECT) | |
sys.path.insert(0, join(PATH_TO_DJANGO_PROJECT, "apps")) | |
PATH_TO_DJANGO_PROJECT = '/path/to/your/project' | |
setup_django_env(PATH_TO_DJANGO_PROJECT) | |
# these imports will be available in your notebooks | |
from trading.models import * | |
from markets.models import * | |
import numpy as np | |
import pandas as pd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place this script in your
~/.ipython/extensions
folder. You may wish to rename it so it matches your django project.Then activate your virtualenv and start the ipython note notebook server: