Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
surenkov opened this issue Jan 11, 2024 · 0 comments · May be fixed by #49
Open

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

surenkov opened this issue Jan 11, 2024 · 0 comments · May be fixed by #49
Assignees
Labels
enhancement New feature or request pydantic:2

Comments

@surenkov
Copy link
Owner

surenkov commented Jan 11, 2024

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 surenkov self-assigned this Jan 11, 2024
@surenkov surenkov added the enhancement New feature or request label Jan 11, 2024
@surenkov surenkov changed the title [Pydantic 2 only] Serialize query lookups with pydantic_core [Pydantic 2 only] Serialize query lookups with pydantic_core based on the provided schema Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pydantic:2
Projects
None yet
1 participant