django-orm-lens
Provides tools to inspect Django project models, fields, and relationships, enabling AI agents to navigate and understand the Django ORM schema without needing a running Django server.
Django ORM Lens
See your entire Django schema β in your editor, in your terminal, and from your AI agent.
Every app. Every model. Every field. Every relationship. Grouped, navigable, and one keystroke away from a live ER diagram.
β‘ Install
VS Code / Cursor / Windsurf / any Code fork:
code --install-extension frowningdev.django-orm-lensOr 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 agentsRequires Python 3.9+. Zero runtime dependencies for the CLI.
Related MCP server: django-mcp-inspector
π― The problem
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.
β¨ 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.
π¨ Native VS Code UI
Dark theme. Light theme. Your theme. Follows your icon theme, your font, your key bindings. Nothing garish, nothing branded.
πΈ What it looks like
π€ For terminals and AI coding agents
The 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.
CLI
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 diagramEvery command accepts --path <dir> and --exclude <glob>.
MCP server
Register it once with your agent and it exposes five read-only tools:
Tool | Purpose |
| Every Django app in the workspace with model counts |
| Flat |
| Full field / relation / Meta detail for one model |
| Inbound + outbound relations for one model |
| Mermaid |
# Start it directly
django-orm-lens-mcp
# Or via the CLI subcommand
django-orm-lens mcpSet DJANGO_ORM_LENS_ROOT=/abs/path/to/project to point it anywhere.
π Integrations
Client | How to enable | Status |
VS Code |
| β |
Cursor | same VSIX + optional MCP entry in | β |
Windsurf / VSCodium / any Code fork | install the VSIX from the Marketplace or GitHub Releases | β |
Aider | add | β (via MCP) |
Continue.dev | register the MCP server in | β (via MCP) |
Zed | register the MCP server in Zed settings | β (via MCP) |
Any MCP-compatible client | point | β |
Discoverable via MCP Registry | official Model Context Protocol server directory | β |
Plain terminal / CI |
| β |
Example: Cursor / any MCP client
{
"mcpServers": {
"django-orm-lens": {
"command": "django-orm-lens-mcp",
"env": { "DJANGO_ORM_LENS_ROOT": "/abs/path/to/your/project" }
}
}
}π Get started (30 seconds)
In VS Code:
code --install-extension frowningdev.django-orm-lensOpen a folder with a
manage.pyormodels.pyClick the Django ORM Lens icon in the activity bar
Expand apps β models β fields
Click the type-hierarchy icon at the top of the panel β ER diagram opens beside your code
In a terminal:
pip install django-orm-lens
cd my-django-project
django-orm-lens scan -f tableAs 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.
π€ How is this different?
Django ORM Lens |
|
| Django Admin | |
Works without a bootable Django project | β | β | β | β |
Zero-install (no graphviz, no server) | β | β | β | β |
Sidebar tree inside the editor | β | β | β | β |
Live ER diagram | β | β | β | β |
Hover cards on | β | β | β | β |
Split | β | β οΈ | β οΈ | β |
CLI for terminal / CI | β | β οΈ | β | β |
MCP server for AI agents | β | β | β | β |
Free & open-source | β | β | β | β |
βοΈ Configuration
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 |
|
| See above | Glob patterns to skip when scanning |
|
|
| Rescan on |
π§ Commands
Open the command palette (Ctrl+Shift+P / Cmd+Shift+P) and type "Django ORM Lens":
Command | What it does |
| Force-rescan the workspace |
| Open the Mermaid ER diagram side-by-side |
| Filter the tree by app / model / field name |
| Restore the full tree |
| Programmatic β triggered by tree clicks and hover cards |
πΊοΈ Roadmap
Shipped
Sidebar tree grouped by app
Live Mermaid ER diagram
Hover cards over
ForeignKey('app.Model')Filter tree by name
Split
models/package supportExport ER diagram as SVG
Python CLI + MCP server for terminals and AI agents
Welcome view for empty workspaces
Path-safe jump-to-definition and sanitized hover markdown
Next (v0.3.0)
CodeLens above each
class Model:N relations Β· N fields Β· Open ERDEdge labels on the diagram:
CASCADE,SET_NULL,PROTECT,related_nameZoom + minimap + auto-layout inside the webview
Named color themes (default / ocean / sunset / forest / dark)
App / model toggle checkboxes to declutter huge schemas
Later
Migration dependency graph
ORM query autocomplete inside
.filter()/.exclude()/.annotate()Third-party field support (
django-mptt,django-taggit,django-model-utils)JetBrains / PyCharm plugin (if there is demand)
Vote by π-ing the corresponding issue.
β FAQ
π Support
π Bug reports β GitHub Issues (please include a minimal
models.pysnippet)π‘ Feature requests / ideas β GitHub Discussions
π Marketplace reviews β rate the extension (the fastest signal that keeps this project moving)
π PyPI page β pypi.org/project/django-orm-lens
π Sponsor β github.com/sponsors/FROWNINGdev
π License
MIT Β© FROWNINGdev
Made for developers who care about their codebase.
Marketplace Β· PyPI Β· GitHub Β· Issues Β· Discussions Β· Sponsor
Maintenance
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/FROWNINGdev/django-orm-lens'
If you have feedback or need assistance with the MCP directory API, please join our Discord server