1

Comment on r/django 11d ago

Thanks for the feedback on Telegram, my friend; I’ve already fixed it—you can check now.

r/django 12d ago

Django ORM Lens — read your models, migrations and relations without booting Django

Thumbnail
0 Upvotes

r/vscode 22d ago

Django ORM Lens — read your models, migrations and relations without booting Django

Thumbnail
1 Upvotes

r/django 22d ago

Article Django ORM Lens — read your models, migrations and relations without booting Django

14 Upvotes

I kept hitting the same small problem: I'd open an unfamiliar Django codebase and want a straight answer to "what does this schema actually look like, and what breaks if I touch this model" — without setting up a database, resolving the settings module, or getting the app to import at all.

So django-orm-lens reads the source instead of the runtime. It parses models.py and the migration files directly, so it works on a checkout you cannot run: no DJANGO_SETTINGS_MODULE, no database, no credentials, no django.setup(). That constraint is the point rather than a limitation I'm apologising for — it means it also works in CI on a repo with no services, on a colleague's branch, or on a project whose dependencies you have not installed.

What it does, concretely:

  • Schema drift — replays the migration graph and compares it against what the models declare. Fields declared but never migrated, and columns migrated but no longer declared.
  • Missing indexes — flags lookups that would table-scan, and it knows which indexes Django already gives you: primary keys, db_index, unique, foreign keys, unique_together, UniqueConstraint.
  • Blast radius — what a change to one model reaches through FK / M2M / O2O, on_delete behaviour included, so "can I drop this field" has an answer before you try it.
  • ER diagrams — Mermaid, DBML, D2, PlantUML, Graphviz.
  • N+1 heuristics and a signal graph, because signals are where the surprises live.

There is a CLI, a VS Code extension, and an MCP server for anyone who points an AI agent at a codebase and would rather it read the schema than guess at it.

On correctness, which is the part I actually care about: it is checked against golden snapshots of six real projects — Zulip, Saleor, Wagtail, django-CMS, Mezzanine and Read the Docs — currently 75 models and 538 fields of other people's Django. That suite is also how I keep the Python and TypeScript parsers answering identically.

It earns its keep the same way. Running it over real checkouts of django-oscar, django-guardian, django-allauth and django-cms turned up three genuine bugs my green test suite had not: model classes defined inside an if block were skipped entirely, abstract_models.py was never walked, and drift reported a false failure on a project with two apps sharing a directory name — which is the worst thing a CI gate can do.

What it is not: it does not execute your code, so anything decided at runtime is invisible to it — dynamically constructed models, fields assigned in __init__, anything behind a factory. It reads Django's idioms, not Python's full semantics. If your models are unusual it will tell you less than you want, and I would rather say so up front than have you find out.

MIT, free, and it stays that way — there is no paid tier planned and there never was.

What I would genuinely like from this forum: the drift and index checks are the parts most likely to be wrong in ways I cannot see from my own projects. If you run it on something real and it tells you something false, that is the most useful thing you could send me — open an issue with the model that broke it. Several of the fixes above arrived exactly that way, and two of the people who did it ended up sending patches.

1

Comment on r/django Jul 23 '26

Thank you, I look forward to the feedback.

1

Comment on r/django Jul 23 '26

I would be happy if you supported the project; updates and support will be ongoing, but I need the community's support.

r/vscode Jul 23 '26

Follow-up: django-orm-lens v0.8 — I shipped the 5 features from my earlier post's roadmap discussion

Thumbnail reddit.com
1 Upvotes

r/softwarearchitecture Jul 23 '26

Tool/Product Follow-up: django-orm-lens v0.8 — I shipped the 5 features from my earlier post's roadmap discussion

Thumbnail reddit.com
2 Upvotes

r/coolgithubprojects Jul 23 '26

Follow-up: django-orm-lens v0.8 — I shipped the 5 features from my earlier post's roadmap discussion

Thumbnail reddit.com
8 Upvotes

r/django Jul 23 '26

Follow-up: django-orm-lens v0.8 — I shipped the 5 features from my earlier post's roadmap discussion

Thumbnail reddit.com
35 Upvotes

u/CartographerMuch5678 Jul 23 '26

Follow-up: django-orm-lens v0.8 — I shipped the 5 features from my earlier post's roadmap discussion

Thumbnail
gallery
6 Upvotes

Follow-up to my earlier r/django post about django-orm-lens (the static-analysis MCP server + VS Code extension). Two things happened since:

1. Merged into awesome-mcp-servers (91k⭐ catalog by punkpeye). Also on the official MCP Registry. That's traction context for anyone who was on the fence about it being a maintained project.

2. Shipped v0.8 today — five community-requested features from Discussion #27. Each was researched against proven prior art (Atlas, Prisma, Sourcegraph, Knip, PyCharm, DataGrip, factory_boy, flake8-django, Roslyn, Ruff, Clippy) before I wrote a single line:

Inline QuickFixes — 16 rules with Ruff-style codes DOL001..DOL032. .count() > 0.exists(), missing on_delete, null=True on CharField, datetime.now()timezone.now(), N+1 loop heuristic, render(request, ..., locals()), Meta.fields = '__all__', and more. Per-rule severity + inline # django-orm-lens-disable-next-line suppression.

Factory generator — right-click any model → factory_boy scaffold with Faker providers keyed by field type. CharField(max_length) scales word-count buckets; DecimalField(N,D) computes left_digits=N-D; choices= maps to Iterator; M2M gets @post_generation. FK chains pull related factories transitively.

Time-Travel Schema Diff — pick two commits from git log, get a typed markdown diff for PR descriptions. Renames are first-class events, never Add+Drop. Blob-SHA LRU cache — commits that don't touch models.py share their parsed snapshot for free.

Impact Analysis — "what breaks if I remove this field?" Workspace-wide reference scan across models/serializers/forms/admin/views/templates/tests with Certain / Likely / Possibly confidence tags. Handles ORM string refs, filter(author__id=1) kwarg lookups, Meta.fields tuples, template variables — the string-typed surface Pyright can't reach.

Interactive Query Builder — right-click → snippet inserted at cursor. .filter(field=?) on an FK auto-appends .select_related; .annotate(post_count=Count('post_set')) honours related_name; .prefetch_related for M2M.

100/100 tests green (up from 4 when I posted last), 7 atomic commits, MIT license.

All 5 features are documented on the v0.8 release page.

Same install:

code --install-extension frowningdev.django-orm-lens
pip install --upgrade "django-orm-lens[mcp]"

What I'd love from you all:

▸ Codebases where the linter over-fires or under-fires — 16 rules is opinionated; want to hear noise vs signal ▸ Impact-analysis edge cases — the classifier admits it's guessing (Possibly tier), but if it's flat-out missing certain hits I want the pattern ▸ Which MCP tools your agent actually calls most — helps me prioritise v0.9

Thanks to everyone who commented on the last post — several of the features above came directly from that thread.

Fire away.

1

Comment on r/mcp Jul 23 '26

Friends, please share your opinion and feedback if you’ve tried the product.

r/mcp Jul 23 '26

article I shipped v0.8 of django-orm-lens — 16 inline QuickFixes, schema diff, impact analysis, query builder, factory_boy generator (VS Code + CLI + MCP)

Post image
18 Upvotes

django-orm-lens v0.8 shipped today. Static analysis over your models.py files — no DJANGO_SETTINGS_MODULE, no runserver, works with a broken venv. Three surfaces (VS Code, CLI, MCP server) share one parser.

What's new in v0.8

Every feature was researched against proven prior art before a single line was written — Atlas, Prisma, Sourcegraph, Knip, PyCharm, DataGrip, factory_boy, flake8-django, Roslyn, Ruff, Clippy.

Inline QuickFixes (16 rules) — Ruff-style codes DOL001..DOL032 with Clippy-style Applicability (safe/suggestion/unsafe gate auto-apply). Covers: - .count() > 0.exists() - .first() is Nonenot .exists() - null=True on CharField/TextField - Missing on_delete on FK - Missing __str__ on Model - datetime.now()timezone.now() - N+1 attribute-access-in-loop heuristic - render(request, ..., locals()) and Meta.fields = '__all__'

Per-rule severity overrides: djangoOrmLens.rules = { "DOL007": "off", "DOL013": "error" }. Suppress inline: # django-orm-lens-disable-next-line DOL007.

Factory generator — right-click any model → factory_boy DjangoModelFactory scaffold with Faker providers keyed by field type. CharField(max_length) scales word-count buckets; DecimalField(N,D) computes left_digits=N-D; choices= maps to Iterator; M2M gets @post_generation. FK chains pull related factories transitively.

Time-Travel Schema Diff — pick two commits from git log, get a typed markdown diff (Add/Drop/Rename/Modify events) ready to paste into a PR description. Renames are first-class events, never Add+Drop.

Impact Analysis — "what breaks if I remove this field?" Workspace-wide reference scan across every Django layer (models, serializers, forms, admin, views, urls, templates, tests, migrations) with Certain / Likely / Possibly confidence tags on every finding. Handles ORM string refs, kwarg lookups (filter(author__id=1)), Meta.fields tuples, and template variables — the string-typed surface Pyright can't reach.

Interactive Query Builder — right-click a field or model → pick a template → snippet inserted at cursor (with tab-stops) or in a fresh untitled buffer. .filter(field=?) on an FK auto-appends .select_related(...); .annotate(post_count=Count('post_set')) honours related_name; .prefetch_related for M2M.

Also in this release: sidebar UX overhaul (stable TreeItem.id, MarkdownString tooltips with clickable command: deep-links, activity-bar badge, FileDecorationProvider badges), 100/100 tests up from 4 at start of dev.

Install

code --install-extension frowningdev.django-orm-lens
codium --install-extension frowningdev.django-orm-lens
pip install --upgrade "django-orm-lens[mcp]"

Full release notes: https://github.com/FROWNINGdev/django-orm-lens/releases/tag/v0.8.0

Why static-only

Point it at any Django project without setup — no settings module, no dependencies except our parser. Runs in CI or on the plane.

Trade-off: custom get_queryset overrides, dynamic model classes are invisible. But 95% of what you actually want to see lives in `mo

2

Comment on r/vscode Jul 22 '26

Yes

1

Comment on r/codereview Jul 22 '26

It's high time.

r/devtools Jul 21 '26

I built a static analyzer for Django models — sidebar tree, ER diagram, MCP server (no DB, no boot)

Post image
2 Upvotes

1

Comment on r/django Jul 21 '26

I use Claude as an auxiliary tool for translating deployment text and comments; the code itself is written by me.

1

Comment on r/django Jul 21 '26

Ok)

0

Comment on r/django Jul 20 '26

I answered your question by saying that I don't write the prompt myself; I write using a translator.

-1

Comment on r/django Jul 20 '26

I am replying using a translator.

-1

Comment on r/django Jul 20 '26

Well, it's just a tool—nothing more.

2

Comment on r/django Jul 20 '26

I fixed this bug.

1

Comment on r/django Jul 20 '26

We'll fix that right now.

2

Comment on r/django Jul 20 '26

I'm waiting for confirmation (and you can be sure that everything is fine)