You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
The approach in https://github.com/tiangolo/sqlmodel has me interested exploring a combined model for Django and Pydantic. I would consider doing a PR to that project, though it seems too specific to SQLAlchemy and FastAPI for a Django-specific implementation to be a good fit (also don't know if I'll pursue this at all) - not sure.
Something like this for the model definition:
fromdjantic.modelsimportDjanticModel, FieldclassPlant(DjanticModel):
"""A plant."""common_name: strgenus_name: str=Field(
max_length=100,
help_text="A generic name for a collective group of plants.",
)
specific_epithet: strclassMeta:
ordering= ["genus_name"]
classConfig:
include= ["genus_name", "specific_epithet"]
Then attribute access would (ideally) look like this:
frommyapp.modelsimportPlant# Schema definition from classschema=Plant.schema()
# Export data from instanceplant=Plant.objects.create(genus_name="Grevillea", specific_epithet="buxifolia")
data=plant.dict()
Maybe.
The text was updated successfully, but these errors were encountered:
I'm not sure if it's possible to solve 100% of what can be done with a Django model, but I've gotten a little spoiled by pydantic and every time I write a Django model I think about what could be possible with type annotations. +1 for trying to tackle this either by extending SQLModel or separately!
The approach in https://github.com/tiangolo/sqlmodel has me interested exploring a combined model for Django and Pydantic. I would consider doing a PR to that project, though it seems too specific to SQLAlchemy and FastAPI for a Django-specific implementation to be a good fit (also don't know if I'll pursue this at all) - not sure.
Something like this for the model definition:
Then attribute access would (ideally) look like this:
Maybe.
The text was updated successfully, but these errors were encountered: