(One of my summaries of the 2025 pygrunn conference in Groningen, NL).
Henk works at four digits, a long-time django shop.
He had a poll at the start about peoples’ favourite editor. The top three: pycharm 38%, vscode 37%, neovim 11%. (Bugger, my favourite, emacs, is not in the top three).
Code completion is nice. Modern editors are real handy for this with good support for
django and python. But… for django templates, it is missing. No auto-completion for
{% bl
to {% block
. And also no knowledge of the available variables and
attributes.
Pycharm is an exception, it has django language support and completion for the standard django template tags and also auto-complete in case you have class-based views.
He showed us django template LSP: https://github.com/fourdigits/django-template-lsp, wich implements similar functionality for most other editors.
It also picks up custom template tags.
Docker support! It can find your template tags and code inside a docker image.
When something is not picked up, you can add a comment with a type hint.
You can install it from vscode, the name is djlsp
.
You can build such a LSP, Language Server Protocol, yourself. LSP allows a client (your IDE) to interface with the language server. “A document is opened”, “I’m on line x, character y, is there a hint here?”.
They have a script called django-collector.py
that is run with your project’s python
(with a fallback). It statically analyses your code and returns json for use by the rest
of the LSP mechanism.
There’s an alternative, django language server, started a while after they themselves started their LSP. Written in rust. But there’s not a lot of functionality yet.
Django template LSP is open source, it is in their github repo. They’re using it a lot internally. If you have ideas and pull requests: welcome!
Photo explanation: picture from our Harz (DE) holiday in 2023
My name is Reinout van Rees and I program in Python, I live in the Netherlands, I cycle recumbent bikes and I have a model railway.
Most of my website content is in my weblog. You can keep up to date by subscribing to the automatic feeds (for instance with Google reader):