Replies: 3 comments 4 replies
-
It seems this is related to #406 |
Beta Was this translation helpful? Give feedback.
-
Any suggestion how to adapt this approach to adding a meta field on the (Also commented this on an issue (#406), but I guess discussion may have more chance on receiving an answer) |
Beta Was this translation helpful? Give feedback.
-
@YetAnotherWebDeveloper I developed a workaround for me in my project. I use the common This fixes the n+1 query problem for this fields ;-) @sliverc maybe this could be default behavior to increase the performance for non included related data fields. |
Beta Was this translation helpful? Give feedback.
-
Scenario
In case of using the HyperlinkedRelatedField](https://django-rest-framework-json-api.readthedocs.io/en/stable/usage.html#hyperlinkedrelatedfield) no data will be rendered. Also no meta information is rendered.
If you want to use the
HyperlinkedRelatedField
to increase performance, there is no possibility to add a meta object to that relation.Enhancement
In my case i've got a WmsService Model:
Which is referenced by many layers:
With a custom manager i can collect the meta information optimized with low performance constraints:
Now the meta information is present in the queryset of the view:
I could use the meta information from the queryset for the HyperlinkedRelatedField:
Same behavior could be used for SerializerMethodResourceRelatedField, cause there is also no possibility to pass meta information.
SerializerMethodResourceRelatedField
will only return the data object.Beta Was this translation helpful? Give feedback.
All reactions