How to run the Django Shell in Emacs

How to run the Django Shell in Emacs

Wednesday - January 16, 2019



(defun django-shell ()
  (let ((python-shell-interpreter (read-file-name "Locate "))
        (python-shell-interpreter-args "shell"))
    (run-python (python-shell-calculate-command) nil t)))


I was looking for an easy way to access the Django shell in Emacs. Previously, I used ansi-term and just ran ./ shell like normal. The big problem with this method was that I didn’t get all of the awesome code-completion and similar features that I would get from the run-python shell.

This elisp function prompts the user to locate their file. It then temporarily sets the “python shell interpreter” to and adds “shell” to the argument of run-python is called. It uses python-shell-calculate-command that basically pieces together the interpreter and args variable we set earlier.


Leave a comment