You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 28, 2022. It is now read-only.
The issue here is allowing SerializerSpecPlugin.get_value to see the top level instance (or even the whole trail of instances) as well as its own one which it is passed.
DRF does not pass this info through when serializing nested ModelSerializers so its hard to see how we can get hold of it without adapting/extending DRF which is no minor undertaking.
Another approach could be to rewrite the serialization in SSM not to build nested DRF ModelSerializers at all. Also majorish :(.
My solution to this has been to have a top-level Plugin prefetch the required sub-data in its modify_queryset() or serialization_spec or both, and then push the required things into the model instance tree in its get_value(). Then user.calculated_value will magically be available in the sub serialization-spec.
I think this solution is OK so the only work to do here is to allow a Plugin to not have a key or return anything in its get_value(), as it doesnt output anything directly into the tree where it is included.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Something like this:
The text was updated successfully, but these errors were encountered: