-
Notifications
You must be signed in to change notification settings - Fork 298
Fix included resources not being included on list #307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
77868fc
f0fa0e7
c4513e7
a4e71d5
ede0ad4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,6 +186,13 @@ def get_related_resource_type(relation): | |
relation_model = relation.model | ||
elif hasattr(relation, 'get_queryset') and relation.get_queryset() is not None: | ||
relation_model = relation.get_queryset().model | ||
elif ( | ||
getattr(relation, 'many', False) and | ||
hasattr(relation.child, 'Meta') and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if these There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite understand. If the serializer may not be a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, you're right. I thought a vanilla serializer made no use of |
||
hasattr(relation.child.Meta, 'model')): | ||
# For ManyToMany relationships, get the model from the child | ||
# serializer of the list serializer | ||
relation_model = relation.child.Meta.model | ||
else: | ||
parent_serializer = relation.parent | ||
parent_model = None | ||
|
@@ -266,10 +273,10 @@ def get_included_resources(request, serializer=None): | |
|
||
|
||
def get_default_included_resources_from_serializer(serializer): | ||
try: | ||
return list(serializer.JSONAPIMeta.included_resources) | ||
except AttributeError: | ||
return [] | ||
meta = getattr(serializer, 'JSONAPIMeta', None) | ||
if meta is None and getattr(serializer, 'many', False): | ||
meta = getattr(serializer.child, 'JSONAPIMeta', None) | ||
return list(getattr(meta, 'included_resources', [])) | ||
|
||
|
||
def get_included_serializers(serializer): | ||
|