Skip to content

Commit 94b5554

Browse files
alexahnPeter Kajan
authored and
Peter Kajan
committed
try to use field.remote_field instead of field.related (django-json-api#255)
1 parent bbfdf21 commit 94b5554

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

rest_framework_json_api/utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ def get_related_resource_type(relation):
199199
# Django 1.7
200200
relation_model = parent_model_relation.related.model
201201
elif hasattr(parent_model_relation, 'field'):
202-
relation_model = parent_model_relation.field.related.model
202+
try:
203+
relation_model = parent_model_relation.field.remote_field.model
204+
except AttributeError:
205+
relation_model = parent_model_relation.field.related.model
203206
else:
204207
return get_related_resource_type(parent_model_relation)
205208

0 commit comments

Comments
 (0)