Skip to content

Commit 54cce05

Browse files
author
Nick Meyer
committed
Update utils.get_related_resource_type to check for relation.source before falling back to parent_serializer
1 parent e6bb75f commit 54cce05

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

rest_framework_json_api/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ def get_related_resource_type(relation):
151151
parent_model = parent_serializer.parent.Meta.model
152152
parent_model_relation = getattr(
153153
parent_model,
154-
(relation.field_name if relation.field_name else parent_serializer.field_name)
154+
(relation.field_name if relation.field_name else
155+
(relation.source if relation.source else parent_serializer.field_name))
155156
)
156157
if hasattr(parent_model_relation, 'related'):
157158
relation_model = parent_model_relation.related.model

0 commit comments

Comments
 (0)