Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use correct serializer for rendering
Ensure that the correct resource is returned during rendering, which in turn requires to use the correct serializer, depending on if it is a related resource or the parent resource.
sliverc pointed out the issue here.
  • Loading branch information
uliSchuster committed Nov 10, 2020
commit 5c4cb88a38ef809f182c5fc6eb25ee6d3db74fd6
5 changes: 4 additions & 1 deletion rest_framework_json_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ def get_resource_name(context, expand_polymorphic_types=False):
resource_name = getattr(view, 'resource_name')
except AttributeError:
try:
serializer = view.get_serializer_class()
if 'kwargs' in context and 'related_field' in context['kwargs']:
serializer = view.get_related_serializer_class()
else:
serializer = view.get_serializer_class()
if expand_polymorphic_types and issubclass(serializer, PolymorphicModelSerializer):
return serializer.get_polymorphic_types()
else:
Expand Down