django-pydantic-field icon indicating copy to clipboard operation
django-pydantic-field copied to clipboard

[Pydantic 2 only] Serialize query lookups with `pydantic_core` based on the provided schema

Open surenkov opened this issue 1 year ago • 0 comments

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.

surenkov avatar Jan 11 '24 19:01 surenkov