Skip to content

Commit 028e7e6

Browse files
author
Leifur Halldor Asgeirsson
committed
In OPTIONS responses, indicate include support
In the body of responses to OPTIONS requests, add an attribute 'allows_include' to related fields indicating whether the endpoint supports including this resource via the include parameter.
1 parent 2faeca2 commit 028e7e6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

rest_framework_json_api/metadata.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,7 @@ def get_field_info(self, field):
131131
for choice_value, choice_name in field.choices.items()
132132
]
133133

134+
if hasattr(serializer, 'included_serializers') and 'relationship_resource' in field_info:
135+
field_info['allows_include'] = field.field_name in serializer.included_serializers
136+
134137
return field_info

0 commit comments

Comments
 (0)