Django ER diagrams, N+1 detection, schema drift & migration-risk linting — in VS Code, a CLI and an MCP server. Static analysis: no database, no django.setup(). Free & MIT.
**English** · Русский · Español · 中文
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
Django ORM Lens
ER diagrams, N+1 detection and migration-risk checks for Django — without booting it.
Your entire model graph — live in your editor sidebar, gating your CI, and answering your AI agent over MCP. All from static parsing: no database, no runserver, no working venv.
**Replaces:** graph_models + django-schema-graph + hand-drawn ER diagrams + grep archaeology.
Featured in Django News #347 · PyCoder's Weekly #746
---
⚡ 10 seconds to first insight
Cold clone, broken venv, no settings module — you still see every app and model of the project, then the N+1 loops and risky migrations in it, right in your terminal. (uvx is from uv; pipx run works the same way.)
**Then pick your surface** — three distributions, one parser core:
| You are | Install | You get |
|---|---|---|
| **Editor user** — VS Code / Cursor / Windsurf / VSCodium | code --install-extension frowningdev.django-orm-lens | Field autocomplete in .filter(), sidebar tree, live ER diagram, hover cards, 18 lint rules with QuickFixes |
| **Terminal / CI user** | pip install django-orm-lens | 17 subcommands, SARIF + PR annotations, pre-commit hooks, a GitHub Action |
| **AI-agent user** — Cursor / Claude Code / Aider / Zed / Continue | pip install "django-orm-lens[mcp]" | 13 read-only MCP tools answering schema questions from ground truth |
MCP setup is one JSON block — see Integrations. Point DJANGO_ORM_LENS_ROOT at your Django project's absolute path.
---
🆓 Paid-tier capabilities, free and MIT
Schema review is a paid category nearly everywhere. A bot that reviews every pull request, analysis that follows a queryset past the function it was built in, a check that catches schema drift, index advice grounded in real table statistics — those normally sit behind a per-seat or per-database subscription.
All of it is here, MIT-licensed, with no tier gate, no seat count, no account, and no telemetry:
| Capability usually sold as a paid tier | Here |
|---|---|
| PR review bot for schema changes — posts once, then updates in place | blast-radius + the Action |
| Analysis that follows a queryset across functions | nplusone |
| Schema drift detection | drift |
| Index proposals from observed QuerySet usage | suggest-indexes |
| Migration risk weighed against real table sizes | blast-radius --stats |
| Blast radius of a destructive migration | blast-radius |
| Cross-layer impact of removing a field | impact |
**There is no Pro tier, and none is planned.** If the tool saves you an afternoon, a star is the entire ask.
---
📊 Traction
> If the tool saves you a grep next time you touch a strange Django project — **a star helps others find it**.
📈 Star growth
---
⚡ Install
**VS Code / Cursor / Windsurf** (VS Code Marketplace):
**VSCodium / code-server / Gitpod / any OSS Code fork** (Open VSX):
Or search **Django ORM Lens** in the Extensions view — same publisher frowningdev on both registries.
**Terminal & AI coding agents:**
Requires Python 3.9+. Zero runtime dependencies for the CLI.
**Docker (v0.6+):**
Multi-arch (amd64 + arm64). No Python required on the host. Good for CI and one-off audits.
🎯 The problem
> **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 Order model, and how is it connected to User?"_
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.**
✨ With Django ORM Lens
📚 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.