django-pydantic-field
django-pydantic-field copied to clipboard
[Pydantic 2 only] Serialize query lookups with `pydantic_core` based on the provided schema
Since Pydantic v2, it looks feasible to walk through the what-is-called CoreSchema
, which is used by pydantic_core
to perform the data validation/serialization.
This opens up the door to get rid of DjangoJSONEncoder
, which the only responsibility left in 0.3.*
is to serialize lookup parameters. It's still not possible to perform a partial model serialzation right out of the box (especially if we're talking about nested schemas), but at least now we could traverse inner structure through the model's core schema, extract particular schema definition for the lookup and perform a serialization with it.