Replies: 1 comment
-
UPD: I see elif "Config" in namespace:
config = namespace["Config"]
model = config.model
fields = getattr(config, "model_fields", None)
exclude = getattr(config, "model_exclude", None)
optional_fields = getattr(config, "model_fields_optional", None)
warnings.warn(
"The use of `Config` class is deprecated for ModelSchema, use 'Meta' instead",
DeprecationWarning,
stacklevel=2,
) But I don't quite get how to use Config in BaseModel(Schema) I want to set camelise for all my model Schemas, it's kinda annoying to put it everywhere
But I get
I've tried to copy meta, but no luck class CamelisedSchema(Schema, metaclass=ResolverMetaclass):
class Config:
from_attributes = True # aka orm_mode
alias_generator = camelize
populate_by_name = True
class CamelisedModelSchema(CamelisedSchema, metaclass=ModelSchemaMetaclass):
pass It ignores class AdminSoftwareListSchema(CamelisedModelSchema):
id: int
status: SoftwareStatus
class Meta:
model = Software
fields = ["id", "name", "category", "status", "cover", "description", "url", "vendor", "short_description"] I got schema only with |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I see here Config + model_fields
https://django-ninja.dev/guides/response/config-pydantic/?h=alias_generator
but here I see Meta + fields https://django-ninja.dev/guides/response/django-pydantic/
Plus AFAIS Meta doesn't support
alias_generator
+populate_by_name
So I have to use both...
So what's the preferred way here?
Beta Was this translation helpful? Give feedback.
All reactions