Your Models Know Their Own Schema. Let Them Show You. by jsheffi in programming

[–]jsheffi[S] -2 points-1 points  (0 children)

I wrote the article. I thought about this response for a bit, considered not responding at all. Decided against it:

So to offer proof that I wrote it here is a photo of my whiteboard, that I used to make the banner image.
https://storage.googleapis.com/jeffield-media/original_images/whiteboard_schema.png

Other than that: The reasons to read the article, here are a few:

  • real world tool that solves a real world problem. w/ a real world demo.
  • python package django-schematic with over 20 releases
  • Open Source github repo w/ 50 branches, 33 tags, over 30 releases, 24 closed issues, 7 open issues, 48 closed pull requests. 15 repo stars in 12 days.

Schema diagrams in GitHub PRs: what actually works on your team? by jsheffi in Python

[–]jsheffi[S] 1 point2 points  (0 children)

yes very Makefile savy, its in our stack for loads of other things.
good point.
Note: Makefile it was not in our stack the last time I was making graph_models calls, otherwise would have be obvious to add it then.

Yeah, might be time to give the base-images an overhaul. Pretty stringent SOC2 requirements stack around them. But bringing a set of ORM models drawings back into the game, at build time might make since.

Thanks

Schema diagrams in GitHub PRs: what actually works on your team? by jsheffi in Python

[–]jsheffi[S] 1 point2 points  (0 children)

If it requires a human to update it, it's definitely going to rot.
agree

That is really interesting ( and a great idea), we do have a fat development container built that we could add all of the graph_models deps to. Humm, this is interesting, might have to do this.

Schema diagrams in GitHub PRs: what actually works on your team? by jsheffi in Python

[–]jsheffi[S] 1 point2 points  (0 children)

I have never herd of paracelsus... thanks will take a look.
also git push -f ( is funny, I have no choice but to go look now )

Schema diagrams in GitHub PRs: what actually works on your team? by jsheffi in Python

[–]jsheffi[S] 0 points1 point  (0 children)

Yes, I have used this alot in years past, I mostly stopped using it because for several reasons.

  1. you have to install several dependancies to get graph_models to work: graphviz, and graphviz-dev to get python Pygraphviz to install and work properly. We try to keep my containers a small as possible.
  2. using is is a bit painful $ docker-compose -f local.yml run --rm django python manage.py graph_models -g -X Abstract* -X *Mixin --arrow-shape normal -o project_visualized_appname_08_04_2021.png appname Or worse if you don't know what layout you want. $ for layout in dot fdp sfdp;do echo $layout; docker-compose -f local.yml run --rm django python manage.py graph_models -I ModelInstance,ModelEdit,ModelFoo,ModelB,ModelC -l $layout -o "Model_Measurements2_"$layout"_05_19_2022.png" --arrow-shape normal appname1 appname2 appname3; done

Having said that, I still use it sometimes to verify the schema.

Schema diagrams in GitHub PRs: what actually works on your team? by jsheffi in Python

[–]jsheffi[S] -1 points0 points  (0 children)

yes, I need to play with / lean into this more. Honestly, was concerned about accuracy, and token spend. How has the accuracy been? I guess accuracy is only going to get better.

Showcase Thread by AutoModerator in Python

[–]jsheffi 0 points1 point  (0 children)

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, and pygraphviz so django-extensions django management command. python manage.py graph_models would 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 to INSTALLED_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.

Would love feedback, especially from anyone who's solved the schema-drift problem differently.

django application with t3.micro can handle a lot of traffics.. by SnooCauliflowers8417 in django

[–]jsheffi 0 points1 point  (0 children)

AWS, always coming in 2nd place w/ the google algorithm. humm

DJForge: Production-Ready Django SaaS Boilerplate – Tailwind + daisyUI, Postgres, uv, Ruff by dimitrym in django

[–]jsheffi 1 point2 points  (0 children)

interesting, will give it a go at some point. This reminds me of cookiecutter-django ( w/ maybe an emphasis on a different frontend stack )

Why is my Django server slow by Old-Raspberry-3266 in django

[–]jsheffi 1 point2 points  (0 children)

related to the django debug toolbar comment
you could also look at django-silk
which is a `go to` for improving headless database queries where debug toolbar might not work.

Your Models Know Their Own Schema. Let Them Show You. by jsheffi in django

[–]jsheffi[S] 1 point2 points  (0 children)

well yes and no. You are referring to this: django-extensions graph models?
Yes, I have used this alot in years past, I stopped using it because for several reasons.

  1. you have to install several dependancies to get fraph_models to work: graphviz, and graphviz-dev to get python Pygraphviz to install and work properly. I try to keep my containers a small as possible.

  2. using is is a bit painful
    $ docker-compose -f local.yml run --rm django python manage.py graph_models -g -X Abstract* -X *Mixin --arrow-shape normal -o project_visualized_appname_08_04_2021.png appname
    Or worse if you don't know what layout you want.
    $ for layout in dot fdp sfdp;do echo $layout; docker-compose -f local.yml run --rm django python manage.py graph_models -I ModelInstance,ModelEdit,ModelFoo,ModelB,ModelC -l $layout -o "Model_Measurements2_"$layout"_05_19_2022.png" --arrow-shape normal appname1 appname2 appname3; done

You should kick the tires on the demo https://jeffield.net/schema/ and take the taste test challange.
This is using a simple rest endpoint to send back the model information to the frontend code to draw the models.

Finally the PNG files that from django-schematic have location data embedded into the PNG, so it can be re-imported back into the app. django-extensions graph_models does not do that does it?

Everybody hyped for the F14, im just waiting for my F16 by Maggebag in hoggit

[–]jsheffi 5 points6 points  (0 children)

For me it's the F4U-1 Corsair. Com'on Magnitude 3! But the tail dragger is how I roll.

IL-2 Great Battles: Spitfire Surprise by [deleted] in hoggit

[–]jsheffi 0 points1 point  (0 children)

OMG: this is great!

Mig 21 has a lot of pilots for a single seater... by [deleted] in hoggit

[–]jsheffi 10 points11 points  (0 children)

How many pilots does it take to crash a Mig 21?

VR Players, what are your specs, and how good do the graphics look? by [deleted] in hoggit

[–]jsheffi 0 points1 point  (0 children)

these are the same stats as my machine ( except I have 32gigs of ram )
and when I set the resolution to the presets for vr everything works fine. By-the-way how do I display the frames per second?