Pydantic / Schema: pass the entire dataset to a nested field #1046
Unanswered
khan-asfi-reza
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using django, django-ninja framework to replace some of my apis ( written in drf, as it is becoming more like a boilerplate codebase ). Now while transforming some legacy api to django-ninja, I need to follow the old structure, so the client side doesn't face any issue. Django-ninja helped a lot to reduce a lot of boilerplate codes and helped to increase the code readability. This is just the backstory.
Now coming to the issue:
I have two separate models.
The structure written in django rest framework serializer
In viewset the following queryset will be passed
I have the following code for pydantic/ninja schema
But as you can see, drf serializer has a parameter called
source
, wheresource="*"
means to pass the entire original dataset to the nested field serializer. Is there any option to do the exact same with pydantic?Except for creating a list of dictionaries
[{author: blog.author, "blog": blog} for blog in queryset]
Beta Was this translation helpful? Give feedback.
All reactions