Django IDE Extension
attention: This extension is still under development and may contain bugs. But does it work? Yes, it does; I use it for work, so I notice bugs and areas for improvement and implement fixes and updates as I go.
Bring PyCharm-like productivity to your Django templates and Python views inside VS Code. This extension leverages a high-performance Rust-powered Language Server (LSP) to offer deep, static analysis and smart integration between your Django back-end views and HTML templates.
Features
⚡ Smart Context Auto-completion
Get autocompletes for context variables in your Django templates. As you type {{, the extension looks up which views render this template and extracts the context variables dynamically.
- Variable Fields: Autocomplete properties on context variables (e.g.,
{{ user. suggests .username, .email).
- Tags & Filters: Complete common Django template filters (
|lower, |default) and blocks.
🔍 Instant View-to-Template Navigation
- Go to Template: Press
Ctrl + Click on a template path string in Python (e.g. render(request, "home.html")) to jump directly to the HTML file.
- Go to View: Use the
Django: Go to View command in an HTML template to quickly see and navigate to all Python views that render this template.
📚 Hover Documentation
Hover over variables inside Django templates to see where they were defined, what view they came from, and their inferred type/details.
🌐 Visual URL & Route Navigation (New in v0.3.0)
Navigate your project's routing map with ease:
- Gutter & CodeLens Icons: Visual markers in
urls.py and view files indicating a registered URL pattern (e.g. ☍ /my-path/).
- Route Quick Actions: Click or hover on a route to copy the resolved URL path to your clipboard or jump to its parent import/definition.
- Document Links: Route patterns in
urls.py are converted into clickable links for immediate navigation.
🧠 Advanced Type Inference & Autocomplete (New in v0.3.0)
- HttpRequest Support: Hovering over
request inside views shows its full fields and methods schema.
- Decorated View Autocomplete: Full autocomplete for request and context variables even inside decorated function-based views (FBVs).
- django-filter Resolution: Resolves types defined in
django-filter FilterSet classes automatically.
🛡️ Smart N+1 Query Diagnostics & Quick Fixes (New in v0.2.0)
Identify database performance bottlenecks statically:
- N+1 Detections: Warns you about loops, parenthesized queries, or property lookups that trigger N+1 query hits.
- Auto-Fix Code Actions: Insert
.select_related() and .prefetch_related() optimizations with one-click editor actions.
How it Works
The extension operates with a modern Client-Server LSP architecture:
- TypeScript Client: Communicates with VS Code APIs, intercepts user inputs, and manages language settings.
- Rust Server: Uses
tree-sitter and ruff_python_ast to index views, map routing, resolve Class-Based Views (CBVs) inheritance, and dynamically build a context model for your templates.
Configuration
The extension requires the standard MS-Python extension to resolve active virtual environments automatically. You can also customize template search directories and configurations.
License
This project is licensed under the MIT License.