python-mode comes with a really nice python shell interpreter which you can send code snippets to using M-x python-shell-send-region. However, when working in a django project it would be even more useful to have this run in a django shell.
You can easily change the interpreter that the python shell interpreter uses in Emacs by adding the following snippet to your .emacs file:
Now when you invoke any of the python shell commands, it will open using the django shell. (In this case, I am using shell_plus from the django_extensions utility, you can also replace this with
shell if you don’t have that installed)
Now, you can send buffers, regions, files, etc. directly to the django shell right from emacs! Fun!