Skip to content

Instantly share code, notes, and snippets.

@lbillingham
Created April 25, 2017 13:48
Show Gist options
  • Save lbillingham/04f90571823685f9b0f4cc8379465369 to your computer and use it in GitHub Desktop.
Save lbillingham/04f90571823685f9b0f4cc8379465369 to your computer and use it in GitHub Desktop.
Django in ipython shell

Use ipython shell with Django

Ordinary Django shell

$ python manage.py shell

does not do autocompletion, doc pretty-printing or other nice-to-have-things.

A way around this is using the ipython shell. We'll assume that both django and ipython are installed (in an active virtualenv), and that the django project in question is called mysite (e.g. made via $ django-admin startproject mysite).

1st set up the environment:

$ export DJANGO_SETTINGS_MODULE=mysite.settings

then launch ipython and wire in django:

In [1]: import django
In [2]: django.setup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment