-
-
Notifications
You must be signed in to change notification settings - Fork 486
RFC: Modelschema rework #1281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
RFC: Modelschema rework #1281
Conversation
78c0646
to
88d2e0c
Compare
16e8c4e
to
78f06eb
Compare
@vitalik Is this MR anywhere in the ballpark of changes you'd like to see? |
07f48a8
to
6260e98
Compare
Hi @Ksauder Sorry have been busy on some other "projects", and if you mark PR as draft it goes a bit under radars If all is good we can start testing - basically our goal for the next release
|
Perfect timing, I have been updating and reviewing django ninja on my project today. I'll review and clean this branch up |
@vitalik I have some docs and test coverage yet to update, but I think this is all for this MR. I have a branch where I'm working through some refactoring to get rid of the Config class, detangle some logic, and get rid of the need for a separate ModelSchema if that is of interest. |
Addresses: #1300 #1249 #995 #347
I was having trouble getting inheritance to work in a logical way with the ModelSchema, so I took a stab at updating the ModelSchemaMetaclass, MetaConf, and some of the SchemaFactory. The added inheritance test shows a concrete example.
I think this rework allows more flexibility and ability to customize moving forward, would love some feedback.
primary_key_optional
option to MetaConf and create_schema() - this toggles how Django fields withprimary_key
are handledI forked and am running my develop branch on a medium (ish? 100+ endpoints) sized project. I have this branch working as intended after some fixes. Here's an example of a project schemas.py file:
nullable_wrapper is a param on a separate branch on my fork, allows a custom type to wrap
nullable
fields:I initially allowed values set in parent ModelSchema.Meta classes to be implicitly passed down to children. I have since removed that. Any inheritance in a Meta class must be explicit, what you see is what you get.
I think it makes sense to move this towards how pydantic itself manages the
model_config
inheritance/overrides.