Simplify from_django by relying in Pydantic. Add multiple level relationship support. #52
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
I open this PR/discussion to:
first_name: str = Field(alias="user__first_name")
). We can replace it by dot aliases if you prefer (first_name: str = Field(alias="user.first_name")
)from_django
logic by relying always that possible in Pydantic, this will increase Djantic performance (reducing serialization time).related_name
or by*_set
and should return a list of instances (from a QuerySet) instead of a instance.Merging this request will cause some breaking changes:
*_set
or the Django's fieldrelated_name
.These changes can be seem in
test_relations.py
andtest_queries.py
.I din't separated this PR in several commits as these changes are linked, but I can separate it if it's hard to understand.
Thank you.