Django with IPython Notebook (Jupyter)

I've used the IPython notebook (now Jupyter) for many years now.  It's a great way for prototyping algorithms or playing around with data using pandas/numpy. And I find it's a great way to learn how to use a new module since the introspection abilities are second to none.  

Now that I have been using Django I've been wanting to get back to using the notebook.  So today I finally took the time to get things up and running with Django.  This tutorial assumes Django 1.8+ and IPython 4.0 but should work with earlier versions of both. If you do run into issues with earlier versions check out this tutorial. Before you start, I would recommend doing everything inside a virtualenv but it should still work if you run with your system python.

First install IPython with notebook dependencies by running:

    $ pip install "ipython[all]"

Now from within your project folder run:

    $ DJANGO_SETTINGS_MODULE=project_name.settings ipython notebook

This assumes that you have a '' file in your main project folder.  If you have a different directory structure just make sure you put the proper path in. 

You should now have the IPython notebook up and running.  If you get any errors about your apps not being loaded yet try running the following before import your models:

    import django

Now you should be able to import all your models and play around with your data.  If you haven't used pandas before I definitely suggest installing it if you would like to plot your data or do any analytics.  The easiest way is to use pip.

    $ pip install pandas

If you have any questions or problems just leave a comment and I will help you out.  Cheers!