Add dynamic serializers functionality to the API that allows to select the fields in the response. #15389
SaschaSchwarzK
started this conversation in
Ideas
Replies: 1 comment
-
I have good news! We've already implemented this exact feature in #15087, and it will be available in the upcoming v4.0 release. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When working with the API directly or with help of pynetbox the amount of data can be huge.
As an example the devices endpoint with all the nested serializes returns a lot of data.
Most of the time all the data is not required, but returned anyway.
A way to solve this could be to allow the fields that should be returned as a url parameter like this:
api/dcim/devices/?fields=id,name,serial
A simple approach would be to change the model serializer to overwrite the default serializer when we get the fields parameter. Then remove the fields in the serializer response that are not in the list.
A more sophisticated approach would be to build this into the DB query as well with the help of values().
Beta Was this translation helpful? Give feedback.
All reactions