RSS Amplifier

Rida Ayed · May 4, 2025

Django python IDE autocompletion in emacs

0
Sign in to vote or save

This page cannot be shown here. You can still read it on the original site — the toolbar below keeps your place in the directory.

Presuming a working python layer , following settings will provide autocompletion. e.g. typing Mymodel.ob will suggest Mymodel.objects for completion. yay basedpyright ~/.spacemacs.d/init.el (defun dotspacemacs/user-config () (use-package lsp-pyright :ensure t :custom (lsp-pyright-langserver-command "basedpyright" ) :hook (python-mode . (lambda () (require 'lsp-pyright ) (lsp)))) ) ...…

Presuming a working python layer, following settings will provide autocompletion.
e.g. typing Mymodel.ob will suggest Mymodel.objects for completion.

yay basedpyright
~/.spacemacs.d/init.el
(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:

djangoDirectory/pyproject.toml
[tool.basedpyright]
venvPath = "/home/ra/.local/share/virtualenvs"
venv = "django-xyz123"
djangoDirectory/Pipfile
[[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"

Read on /posts/django-python-autocompletion-in-emacs/

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.