Django python IDE autocompletion in emacs
Presuming a working python layer, following settings will provide autocompletion.
e.g. typing Mymodel.ob
will suggest Mymodel.objects
for completion.
yay basedpyright
(defun dotspacemacs/user-config ()
(use-package lsp-pyright
:ensure t
:custom (lsp-pyright-langserver-command "basedpyright")
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp))))
)
...
dotspacemacs-configuration-layers
'(
(auto-completion :variables
auto-completion-minimum-prefix-length 1
auto-completion-enable-snippets-in-popup t
auto-completion-enable-help-tooltip t
auto-completion-return-key-behavior 'complete
auto-completion-tab-key-behavior 'cycle ;;'complete 'cycle
auto-completion-enable-sort-by-usage t
auto-completion-idle-delay 0.0
:config
add-to-list 'company-backends '(company-yasnippet company-capf))
)
...
Get these values with pipenv --venv
:
[tool.basedpyright]
venvPath = "/home/ra/.local/share/virtualenvs"
venv = "django-xyz123"
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
django = "==4.2.16"
[dev-packages]
django-types = "*"
pytest-django = "*"
debugpy = "*"
importmagic = "*"
epc = "*"
autoflake = "*"
[requires]
python_version = "3.9"
python_full_version = "3.9.2"