Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

dynamically switch between ResourceRelatedField and HyperlinkedRelatedField#1038

Unanswered
jokiefer asked this question inQ&A
Discussion options

Default Scenario

classWebMapServiceSerializer(ModelSerializer):layers=HyperlinkedRelatedField(queryset=Layer.objects,many=True,# necessary for M2M fields & reverse FK fieldsrelated_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 withoutinclude=layers a simpleHyperlinkedRelatedField shall be used.

Include Scenario

If the request is withinclude=layers parameter, the request will crash cause theHyperlinkedRelatedField 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?

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
1 participant
@jokiefer

[8]ページ先頭

©2009-2025 Movatter.jp