Django template LSP
Project description
Django Template Language Server (LSP)
The Django Template Language Server (LSP) enhances your Django development experience with powerful features for navigating and editing template files. This LSP supports:
Completions
- Custom Tags and Filters: Autocomplete for your custom template tags and filters.
- Template: Suggestions for
extends
andincludes
statements. - Load Tag: Autocomplete for
{% load %}
tags. - Static Files: Path suggestions for
{% static %}
tags. - URLs: Autocomplete for
{% url %}
tags.
Go to Definitions
- Template: Jump directly to the templates used in
extends
andincludes
. - URL Tag: Navigate to the views referenced in
{% url %}
tags. - Tags and Filters: Quickly access the definitions of custom tags and filters.
- Context Variables: Partial support for jumping to context definitions.
Hover Documentation
- URLs: Inline documentation for
{% url %}
tags. - Tags and Filters: Detailed descriptions for template tags and filters.
Support (tested)
- Python: 3.10, 3.11, 3.12
- Django: 3.2, 4.2, 5.0
Install
pip install django-template-lsp
Options
docker_compose_file
(string) default: "docker-compose.yml"docker_compose_service
(string) default: "django"django_settings_module
(string) default (auto detected when empty): ""
Type hints
Due to the highly dynamic nature of Python and Django, it can be challenging to identify the available context data within templates. To address this, basic type hint support is provided directly in the template files:
{# type blog: blogs.models.Blog #}
Editors
Helix
In your global or project languages.toml
add the following
[language-server.djlsp]
command = "djlsp"
[[language]]
name = "html"
language-servers = [ "vscode-html-language-server", "djlsp" ]
Project settings .helix/languages.toml
:
[language-server.djlsp.config]
django_settings_modules="<your.settings.module>"
Neovim
In your lspconfig add the following
require'lspconfig'.djlsp.setup{
cmd = { "<path-to-djlsp>" },
init_options = {
djlsp = {
django_settings_module = "<your.settings.module>"
docker_compose_file = "docker-compose.yml",
docker_compose_service = "django"
}
}
}
VSCode
To use the Django template LSP with VSCode read the following readme
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django_template_lsp-0.9.5.tar.gz
(27.2 kB
view hashes)
Built Distribution
Close
Hashes for django_template_lsp-0.9.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c8f2e1669d58eb61e756e994ea25fb1b0ec5e65e26e83205defef78cac3f4e0 |
|
MD5 | 3a40911786ba928e4ba85ce130f13b51 |
|
BLAKE2b-256 | 4bba86a42796e709c3d85992a1482ca6ca6230766c96ee4ff52885cbbef0f369 |
Close
Hashes for django_template_lsp-0.9.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ee69135149a21019050fbbea27819d5d4ae089dd85a466873e8356b18c39643 |
|
MD5 | 3262233f0a7ef4ef54b157823c1c25da |
|
BLAKE2b-256 | f8143b711d732cfaafbd8df0b6162bb98671c8e26f98dfe5ee4b431eaa8e7829 |