how to start django shell with ipython in qtconsole mode? how to start django shell with ipython in qtconsole mode? shell shell

how to start django shell with ipython in qtconsole mode?


The docs here say:

If you'd rather not use manage.py, no problem. Just set the DJANGO_SETTINGS_MODULE environment variable to mysite.settings and run python from the same directory manage.py is in (or ensure that directory is on the Python path, so that import mysite works).

So it should be enough to set that environment variable and then run ipython qtconsole. You could make a simple script to do this for you automatically.


I created a shell script with the following:

/path/to/ipythonqtconsole --pylab inline -c "run /path/to/my/site/shell.py"

You only need the --pylab inline part if you want the cool inline matplotlib graphs.

And I created a python script shell.py in /path/to/my/site with:

import osworking_dir = os.path.dirname(__file__)os.chdir(working_dir)import settingsimport django.core.managementdjango.core.management.setup_environ(settings)

Running my shell script gets me an ipython qtconsole with the benefits of the django shell.


You can check the code that runs the shell here. You'll see that there is no where to configure what shell is run.

What you could do is copy this file, rename it as shell_qt.py and place it in your own project's management/commands directory. Change it to run the QT console and then you can run manage.py shell_qt.