erdify 0.14.1 — a fix for django-ninja ModelSchema #181
FabianClemenz
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
erdify 0.14.1 is out 🎉
A patch release, out quickly because it corrects something 0.14.0 got wrong.
ModelSchemano longer renders as an empty entity0.14.0 added
--base-classes, which lets you name a Pydantic base defined outside the scanned files —ninja.Schema, or a sharedBaseSchemafrom an internal library. If you pointed it atModelSchema, though, you got this:An empty box beside the real table. django-ninja's
ModelSchema(innerMeta) and ninja-schema's (innerConfig) take their fields from a Django model rather than from the class body, and erdify does not resolve that reference. An empty entity is worse than no support at all — the diagram stops being incomplete and starts being wrong.erdify now detects the shape, skips it, and says so:
The Django model itself still renders as usual. Detection is narrow on purpose: only an inner
Meta/Configthat assignsmodelcounts, so an ordinary Pydantic model with a nested config class — and Django's ownclass Meta— are untouched.An open question, if you use these
Resolving those schemas properly is still open in #171, and what blocks it is a design question rather than an engineering one:
Is a response schema an entity, or just a projection of one?
UserSchemamirrorsUser. Drawing both duplicates the fields and implies a relationship that does not exist. Rendering it only under an opt-in--sources, rendering it as an annotation on the model it projects, or not rendering it at all are all defensible — and they lead to quite different implementations.If you use
ninja.ModelSchemaorninja_schema.ModelSchema: what would you expect to see in the diagram? That answer is the missing piece, not the parsing. #171 is the place for it.Also in this release
The README and the documentation home page now open with a "five frameworks, one diagram" image — the same
User/Orderschema written in SQLModel, SQLAlchemy, Django, Pydantic and dataclasses, converging on the ERD they all produce. It reaches PyPI with this release.📦 Release · 📖 Docs · 📝 Changelog
All reactions