Allow specifying omit/fields params via the Serializer context #17
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.
Why this
I really like the flexibility that drf-dynamic-fields provides on a request level, but I found it lacking an internal way to specify this directly on a Serializer object. I can use a crude hack to extend the wrapped
_request.GET
dict, but I would prefer this PR instead.What it does
This allows passing omit/fields values to drf-dynamic-fields from a lower level API, useful when creating serializers manually, e.g. inside other serializers.
If both
query_params
andserializer.context
specify the same parameters thecontext
takes precedence, since it is the more internal interface.How to use