Using Vim and ScreenSend with Django’s Management Shell
The Vim plugin ScreenSend allows you to interact with any REPL from within Vim. It’s incredibly useful. I use it with psql, Julia, Python, Clojure, and more. You can just as easily use it to interact with REPLs on remote machines.
A powerful debugging tool for Django projects is to do
./manage.py shell. You’ll get an IPython REPL with enough Django stuff loaded so that you can say
from views import * and use the view functions and objects from the command line.
It’s even better to combine with with ScreenSend. However, the IPython REPL by default will auto-indent code you type into it, and it can’t tell if this is already-indented code from your editor. It works sometimes, but other times it messes up the indent, giving you spurious syntax errors.
In the normal IPython REPL, you can turn off auto-indent with the
--simple-prompt flag (the other flags that are supposed to do this don’t work). But you can’t pass this to
manage.py. Instead, use the
--plain flag, and everything will work with ScreenSend. In other words, from within Vim, if you are in the directory with the
manage.py file, the command you want is
:ScreenSend ./manage.py shell --plain (make sure your
.manage.py file is executable).