DEV Community

Jeff Sheffield
Jeff Sheffield

Posted on

Your Models Know Their Own Schema. Let Them Show You.

Django already knows every model in your project, every field, every relationship — down to the last on_delete. So why are you drawing it by hand?

You know the drill. Sprint planning is tomorrow and someone asks "can you send over the schema?" So you open your diagramming tool, spend two hours dragging boxes and drawing arrows, get it looking presentable — and three days later a migration lands and it's already wrong.

That's not a documentation problem. That's a tooling problem.

django-schematic exists because your Django project already knows its own schema. Every model, every field, every relationship — it's all sitting in the model registry right now, precisely defined, perfectly up to date. The only question is why you'd ever draw that information by hand.

pip install django-schematic
Enter fullscreen mode Exit fullscreen mode

Add it to INSTALLED_APPS, mount the URL, open your browser. In under two minutes you're looking at a live, interactive graph of your entire data model — every ForeignKey, every ManyToManyField, every abstract base class, laid out automatically and ready to explore.

Not a screenshot. Not a PDF you'll forget to update. A living diagram that re-generates from your actual code every time you load it.

For the moments that actually matter

When you're onboarding a new developer and they need to understand how User connects to SocialAccount which in turn connects to Token, and SocialApp — you don't send them a Notion page that was accurate in Q2. You send them a PNG schema drawing.

Example User Schema

But this is no ordinary PNG. Embedded invisibly inside the image file are the model names, positions, and layout configuration from the exact view you were looking at. When your co-worker drops it into django-schematic, the app restores that view — same positions, same visible models, same layout. And here's the important part: it reads the current model definitions from their own running Django project to populate the attributes.

The PNG carries the where, your codebase supplies the what. The diagram is always accurate, even if the schema has moved on since you exported it.

That means you can attach schema PNGs directly to pull requests and GitHub issues, right alongside your code. Reviewers see a clear picture of the data model changes at a glance. And when the next PR lands and things shift, updating the diagram is trivial: import the PNG, show or hide any new relationships, adjust the layout if needed, and export again. Thirty seconds, not two hours.

When you're mid-refactor and you need to see whether that cascade delete is going to ripple in three directions or ten — you don't reconstruct the graph in your head. You switch to Auto-Layout and see it.

When a teammate asks "wait, does UserProfile proxy User or extend it?" — you don't dig through migrations. You glance at the schema, where proxy models are marked distinctly from abstract ones.

It gets out of your way

Filter down to just the billing app when the full graph is too noisy. Switch between hierarchical layout (for tracing relationships) and force-directed (for seeing which models cluster naturally). Export a PNG, share it, import it back — it restores your exact view. And by default, none of this is visible in production: DEBUG=False and the route returns 404, no configuration required.

The whole point is that you shouldn't have to think about it. It's there when you need it, accurate because it reads your code directly, and gone (from production) because you'd never expose it there anyway.

Stop drawing. Start seeing.

Your models change frequently. Your understanding of them should too. django-schematic means you're always looking at the truth — not a drawing of what the truth used to be.

See it for yourself at the live demo, or jump in and contribute on GitHub.

Top comments (0)