-
Notifications
You must be signed in to change notification settings - Fork 301
DRF J-A renders nested serializers out of spec. #769
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
Comments
I see your point that nested serializers should actually be serialized as json value. The only thing I am a bit worried about when implementing this is backwards compatibility. If someone uses nested serializer though I guess it would only work with So an implementation could be that nested model serializer continue to be serialized as relations but a deprecation warning will be printed that This is just an idea but open for discussion and PRs. As a side note currently when using using JSONField it is possible to contain any JSON value in attribute which might be used as a workaround till a fix has been developed for this issue. |
Actually it is possible to implement two strategies and configure which one to be used in settings: For now, the first strategy would be set as default with a deprecation warning, and we will change this behavior in the future releases. Or we can think about a mechanism to specify how to treat each nested serializer separately which is even more flexible. |
I like your first idea with a strategy setting. This way the deprecation warning can warn new users which might think nested serializer serialize to json and what they need to do if they want to. And for old users it shows them that they should adjust their code to use |
Hi there.
Json-api spec states:
Source: https://jsonapi.org/format/#document-resource-object-attributes
However, considering this and this any nested serializer would be rendered as resource relations even though the nested structure is not a resource.
The text was updated successfully, but these errors were encountered: