Skip to content

Commit 9514381

Browse files
bashlysssliverc
authored andcommitted
Support many related field
1 parent f9eb277 commit 9514381

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

rest_framework_json_api/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,12 @@ def get_related_resource_type(relation):
219219
# For ManyToMany relationships, get the model from the child
220220
# serializer of the list serializer
221221
relation_model = relation.child.Meta.model
222+
elif (
223+
hasattr(relation, "child_relation")
224+
and hasattr(relation.child_relation, "model")
225+
):
226+
# For ManyRelatedField relationships, get the model from the child relationship
227+
relation_model = relation.child_relation.model
222228
else:
223229
parent_serializer = relation.parent
224230
parent_model = None

0 commit comments

Comments
 (0)