Django ORM Lens ships as three distributions on one core β pick the one that matches your workflow. Each takes under 60 seconds.
Editor user (VS Code / Cursor / Windsurf): install the extension β open any Django project β sidebar tree + ER diagram appear.
code --install-extension frowningdev.django-orm-lens
Terminal / CI user: install from PyPI β run django-orm-lens in any directory that contains Django apps.
pip install django-orm-lens
django-orm-lens # welcome + commands
django-orm-lens scan # scan cwd for apps and models
AI coding agent user (Cursor / Aider / Continue / Zed): install with MCP extras β add one JSON block to your client config.
pip install "django-orm-lens[mcp]"
Then the MCP config snippet in the Integrations section below. Point DJANGO_ORM_LENS_ROOT at your Django projectβs absolute path.
Updated 2026-07-15. PyPI weekly / monthly, GitHub stars / forks, and PyPI / VS Code version badges auto-refresh live.
If the tool saves you a
grepnext time you touch a strange Django project β star helps others find it.
VS Code / Cursor / Windsurf / any Code fork:
code --install-extension frowningdev.django-orm-lens
Or search Django ORM Lens in the Extensions view.
Terminal & AI coding agents:
pip install django-orm-lens # CLI only
pip install "django-orm-lens[mcp]" # + MCP server for AI agents
Requires Python 3.9+. Zero runtime dependencies for the CLI.
Works offline. Works on a broken venv. Works on someone elseβs laptop. Works in CI.
You open a Django project. It has 20 apps. You need to answer a simple question:
βWhich app owns the
Ordermodel, and how is it connected toUser?β
Today, that means: Ctrl+P, βmodelsβ, scroll through 30 hits, open five files, Ctrl+F for class Order, read through 400 lines of ForeignKey('otherapp.Something') strings, try to remember what you learned two files ago.
Half a day gone. Every time. On every project.
| ### π A tree of everything Every app β every model β every field β every `Meta` option. Grouped by application, sorted alphabetically, expandable. Icons distinguish `CharField` from `ForeignKey` from `ManyToManyField` at a glance. | ### πΈοΈ A live ER diagram One command opens a Mermaid entity-relationship diagram of your entire schema. Watch it redraw as you edit. Export to SVG. `ForeignKey`, `OneToOneField`, and `ManyToManyField` become proper cardinality arrows. |
| ### π Hover for relations Hover over `ForeignKey('app.Model')` in any Python file β a card pops up with the target model's fields, relations, and a "Jump to" link. No `Ctrl+F`, no file dialog. | ### π§ Jump-to-definition Click any field in the tree β cursor lands on the exact line. Filter the tree by app or model name. Split `models/` packages are fully supported. |
| ### β‘ Zero configuration No `DJANGO_SETTINGS_MODULE`. No `runserver`. Parses `models.py` statically. Works with a broken venv, a missing dependency, or on someone else's laptop. | ### π¨ Native VS Code UI Dark theme. Light theme. Your theme. Follows your icon theme, your font, your key bindings. Nothing garish, nothing branded. |
Also included in the extension:
CASCADE, through Model, as related_name), theme-aware, one-click SVG exportForeignKey('app.Model') or ManyToManyField(...), with a one-click jump linkclass Model line: field count, relation count, and an Open ER diagram actionauto / default / dark / forest / neutral for the diagram webviewThe same parser that powers the VS Code extension ships as a standalone Python package β with an optional MCP (Model Context Protocol) server so any MCP-compatible AI agent can navigate your Django schema without importing Django or booting your app.
django-orm-lens scan -f json # every app, every model, every field
django-orm-lens describe blog.Post # one model in Markdown
django-orm-lens hover blog.Post # compact hover card
django-orm-lens list | fzf # flat app.Model β pipes anywhere
django-orm-lens er > schema.mmd # Mermaid ER diagram
Every command accepts --path <dir> and --exclude <glob>.
Register it once with your agent and it exposes five read-only tools:
| Tool | Purpose |
|---|---|
list_apps |
Every Django app in the workspace with model counts |
list_models |
Flat app.Model list, optional app filter |
describe_model |
Full field / relation / Meta detail for one model |
find_relations |
Inbound + outbound relations for one model |
er_diagram |
Mermaid erDiagram for the whole workspace |
# Start it directly
django-orm-lens-mcp
# Or via the CLI subcommand
django-orm-lens mcp
Set DJANGO_ORM_LENS_ROOT=/abs/path/to/project to point it anywhere.
| Client | How to enable | Status |
|---|---|---|
| VS Code | code --install-extension frowningdev.django-orm-lens |
β |
| Cursor | same VSIX + optional MCP entry in ~/.cursor/mcp.json |
β |
| Windsurf / VSCodium / any Code fork | install the VSIX from the Marketplace or GitHub Releases | β |
| Aider | add django-orm-lens-mcp to your mcp.json |
β (via MCP) |
| Continue.dev | register the MCP server in ~/.continue/config.json |
β (via MCP) |
| Zed | register the MCP server in Zed settings | β (via MCP) |
| Any MCP-compatible client | point command at django-orm-lens-mcp, set DJANGO_ORM_LENS_ROOT |
β |
| Discoverable via MCP Registry | official Model Context Protocol server directory | β |
| Plain terminal / CI | pip install django-orm-lens && django-orm-lens scan |
β |
{
"mcpServers": {
"django-orm-lens": {
"command": "django-orm-lens-mcp",
"env": { "DJANGO_ORM_LENS_ROOT": "/abs/path/to/your/project" }
}
}
}
In VS Code:
code --install-extension frowningdev.django-orm-lensmanage.py or models.pyIn a terminal:
pip install django-orm-lens
cd my-django-project
django-orm-lens scan -f table
As an AI agent tool:
pip install "django-orm-lens[mcp]"
β¦then register django-orm-lens-mcp in your agentβs MCP config (see the Integrations table above).
No settings screen. No sign-in. No telemetry.
models.py sprawl.related_name?β) without importing the project.runserver, no manage.py migrate, still works.Django ORM Lens sits at the intersection of editor tooling and AI-agent tooling β a slot no existing package covers:
| Segment | Existing option | What it costs you |
|---|---|---|
| Boot-and-graph | django-extensions graph_models |
Requires Graphviz + Django settings + a working DB URL |
| Web-based viewer | django-schema-graph |
Requires a running Django server; hosts one more thing to break |
| Admin panel | Django Admin | Requires runserver + auth + database β great for data, not for architecture |
| Editor plugin | PyCharmβs Django Structure | Locked to PyCharm; no CLI, no AI-agent story |
| MCP server | (none until now) | AI agents guess your schema from source, imperfectly |
Django ORM Lens is the only tool that ships three surfaces from one parser: a VS Code extension (any Code fork), a zero-dep CLI (terminals + CI), and an MCP server (AI agents). All static. All free. All MIT.
| Β | Django ORM Lens | django-extensions graph_models |
django-schema-graph |
Django Admin | PyCharm Django Structure |
|---|---|---|---|---|---|
| Works without a bootable Django project | β | β | β | β | β οΈ |
| Zero-install (no graphviz, no server) | β | β | β | β | β (needs PyCharm) |
| Works in VS Code / Cursor / any Code fork | β | β | β | β | β |
| Sidebar tree inside the editor | β | β | β | β | β |
| Live ER diagram | β | β | β | β | β |
Hover cards on ForeignKey |
β | β | β | β | β οΈ |
| CodeLens on model classes | β | β | β | β | β |
Split models/ package support |
β | β οΈ | β οΈ | β | β |
| CLI for terminal / CI | β | β οΈ | β | β | β |
| MCP server for AI agents | β | β | β | β | β |
| Discoverable in the MCP Registry | β | β | β | β | β |
| Free & open-source (MIT) | β | β | β | β | β (paid IDE) |
| Django version support | 4.0 β 5.2 | latest | 3.2 β 4.1 (stale since 2023) | latest | latest |
django-schema-graphhas not been updated since 2023-05 and does not test Django 5.x.
The defaults are opinionated and sensible. If you need to tweak:
// .vscode/settings.json
{
"djangoOrmLens.excludeGlobs": [
"**/migrations/**",
"**/node_modules/**",
"**/venv/**",
"**/.venv/**",
"**/env/**"
],
"djangoOrmLens.autoRefresh": true
}
| Setting | Type | Default | What it does |
|---|---|---|---|
djangoOrmLens.excludeGlobs |
string[] |
See above | Glob patterns to skip when scanning |
djangoOrmLens.autoRefresh |
boolean |
true |
Rescan on models.py changes |
Open the command palette (Ctrl+Shift+P / Cmd+Shift+P) and type βDjango ORM Lensβ:
| Command | What it does |
|---|---|
Django ORM Lens: Refresh |
Force-rescan the workspace |
Django ORM Lens: Show ER Diagram |
Open the Mermaid ER diagram side-by-side |
Django ORM Lens: Filter Models |
Filter the tree by app / model / field name |
Django ORM Lens: Clear Filter |
Restore the full tree |
Django ORM Lens: Jump to Model |
Programmatic β triggered by tree clicks and hover cards |
Shipped
ForeignKey('app.Model')models/ package supportN fields Β· N relations Β· Open ER diagram)CASCADE, SET_NULL, PROTECT, related_name)auto / default / dark / forest / neutral)through_model on M2M edges (contributed by @kingrubic)Next
.filter() / .exclude() / .annotate() (#3)Later
django-mptt, django-taggit, django-model-utils)Vote by π-ing the corresponding issue.
models/ package. Does that work?models/*.py alongside classic models.py.
models.Model, abstract bases starting with Abstract, common mixins ending in Mixin, and known base names like TimeStampedModel or PolymorphicModel. Non-model classes (ModelAdmin, ModelSerializer, Form, View, Manager, β¦) are filtered out.
command at the installed django-orm-lens-mcp binary. See the Integrations section.
models.py snippet)Thanks to these wonderful people (emoji key) β all contribution types count, not just code. Translations, docs, screenshots, bug reports, and answered questions are all first-class.
New here? See CONTRIBUTING.md β βHow to become a contributorβ and browse good first issue.
frowningdev π» π π¨ π€ π§ π β οΈ π |
Bao π» β οΈ |
This project follows the all-contributors specification. To be added, comment @all-contributors please add @your-username for docs (or code, translation, design, ideas, question, bug, test, tutorial, example, β¦) on any issue or PR.
MIT Β© FROWNINGdev