Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
start ipython notebook including django
import os
if os.environ.get('DJANGO_SETTINGS_MODULE'):
  print "Initializing Django..."
  if not os.path.exists('app/settings.py'):
      os.chdir('..')
  print "(in directory %s)" % os.getcwd()
  try:
    from django_extensions import management
  except BaseException as e:
    print "Could not initialize django -- stacktrace fyi only"
    import traceback
    import sys
    traceback.print_exc()
    print sys.path
  else:
    c.InteractiveShellApp.extensions = ['django_extensions.management.notebook_extension']
else:
 print "DJANGO_SETTINGS_MODULE %s" % ('not set' if 'DJANGO_SETTINGS_MODULE' not in os.environ else 'empty')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.