-
Notifications
You must be signed in to change notification settings - Fork 300
-
Default Scenario
class WebMapServiceSerializer(ModelSerializer): layers = HyperlinkedRelatedField( queryset=Layer.objects, many=True, # necessary for M2M fields & reverse FK fields related_link_view_name='registry:wms-layers-list', related_link_url_kwarg='parent_lookup_service', self_link_view_name='registry:wms-relationships', ) included_serializers = { 'layers': LayerSerializer, }
If the request is without include=layers a simple HyperlinkedRelatedField shall be used.
Include Scenario
If the request is with include=layers parameter, the request will crash cause the HyperlinkedRelatedField drops the data.
So, IF and only IF the include for layers is needed i need to switch the field class for only this attribute to the ResourceRelatedField`to that the data is rendered.
Is there any way to do that simple?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment