-
Notifications
You must be signed in to change notification settings - Fork 14
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
Json field support #20
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #20 +/- ##
===========================================
- Coverage 100.00% 98.73% -1.27%
===========================================
Files 5 5
Lines 154 158 +4
===========================================
+ Hits 154 156 +2
- Misses 0 2 +2 ☔ View full report in Codecov by Sentry. |
@djbios drf-pydantic/src/drf_pydantic/parse.py Lines 333 to 345 in c3f0611
We cannot convert dict to JSON field because JSON can be either a dict or a list, and those are already implemented separately. Is there a specific example of a pydantic model whose field could be converted to JSON field? |
@georgebv What I meant is scalar
|
@djbios can you please elaborate more on the intended relation between pydantic and DRF fields here. My intention is:
What type would correspond to a My solution for situations like this is to allow manually specifying fields in annotation in scenarios where default transformation doesn't work. This would work like: class MyModel(BaseModel):
json_value: Annotated[dict, CustomField(JSONField(binary=False)] This is currently work in progress here: #19 This particular scenario would still be problematic because now |
@georgebv Hm, I see your point now, thanks for the explanation. So, we have to be specific that we expect JSON value, I've pushed an update:
PS Having the ability to force using a particular drf field is a very cool feature, looking forward to it! |
@georgebv seems like the new Pypi package was not released with this change. What is the publishing strategy of the package and when json field support could be expected can be expected? |
Added
serializers.JSONField
support (pydantic'sdict
)