r/Python • u/AutoModerator • Apr 04 '26
Showcase Showcase Thread
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
43
Upvotes
r/Python • u/AutoModerator • Apr 04 '26
Post all of your code/projects/showcases/AI slop here.
Recycles once a month.
1
u/jsheffi Apr 23 '26
django-schematic: auto-layout Django schemas you can customize in seconds and round-trip as PNGs
I got tired of the dev-only container I was maintaining just to install
graphviz,graphviz-dev, andpygraphvizsodjango-extensionsdjango management command.pythonmanage.pygraph_modelswould work. Every new project, same dance.So I asked myself: can I just do this in the browser? JavaScript handles interactive graphs well these days, and Django's model registry already knows everything — every field, every FK, every M2M. Why shell out to Graphviz at all?
The result is
django-schematic.pip install, add toINSTALLED_APPS, mount a URL, done. No system deps.The part I didn't expect to work: PNG export embeds the layout metadata (positions, visible models, filters) directly in the image file. Re-import the PNG later and it restores your exact view — but it reads the current model definitions from your Django project to populate the fields. So the PNG carries the layout, your code carries the truth. They can never disagree ( as long as the tables still exist in the db.
This turns out to be useful for the documentation drift problem: attach a schema PNG to a PR, reviewer sees the data model change. When the schema moves on, someone re-imports, tweaks, re-exports. If it's only attribute changes, no tweak needed — the diagram updates itself on import.
Auto-layout, hierarchical and force-directed modes, per-app filtering, and 404 in production when
DEBUG=False.Blog post: https://jeffield.net/blog/your-models-know-their-own-schema-let-them-show-you/
Live demo: https://jeffield.net/schema/
PyPI: https://pypi.org/project/django-schematic/
GitHub: https://github.com/jsheffie/django-schematic
Would love feedback, especially from anyone who's solved the schema-drift problem differently.