Closed Bishwas-py closed 4 months ago
Created of something like Sourceable
could help.
class Sourceable(BaseModel):
_source_obj: Any | None = None
@model_validator(mode="wrap")
def __validator__(cls, val: Any, next_: typing.Callable[[Any], typing.Self]) -> typing.Self:
obj = next_(val)
obj._source_obj = val
return obj
Creation of custom data should be allowed:
If
posts = Post.objects.all().alive()
is passed toList[PostSchema]
: