M lisp/wv-python.el => lisp/wv-python.el +17 -0
@@ 1,9 1,26 @@
;;; lisp/wv-python.el -*- lexical-binding: t; -*-
+;;; Set this in a .dir-locals.el
+;;; ((nil . ((wv-python/django-managepy-path . "/path/to/your/project/manage.py"))))
+(defvar wv-python/django-managepy-path nil
+ "Path to current project's manage.py file.")
+
+(defun wv-python/django-shell ()
+ (interactive)
+ (if (not wv-python/django-managepy-path)
+ (message "Variable 'wv-python/django-managepy-path' not set. Please configure it in .dir-locals.el.")
+ (let ((default-directory (file-name-directory wv-python/django-managepy-path))
+ (python-shell-interpreter wv-python/django-managepy-path)
+ (python-shell-interpreter-args "shell"))
+ (run-python (python-shell-calculate-command) nil t))))
+
(use-package python
:hook
((python-mode . tree-sitter-mode)
(python-mode . tree-sitter-hl-mode))
+ :bind
+ (:map python-mode-map
+ ("C-c M-p" . wv-python/django-shell))
:config
(setq-default eglot-workspace-configuration
'(:pylsp