Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

JSONRenderer does not extract includes from PolymorphicModelSerializer properly #1190

Open
Labels
@dmuseychuk-invgate

Description

@dmuseychuk-invgate

When usingPolymorphicModelSerializer withJSONRenderer, theextract_included method is retrieving the base polymorphic serializer instead of the specific serializer corresponding to the object instance. This results in theincludes not being processed correctly, as the base polymorphic serializer is not equipped to handle the specifics of each derived instance.

It appears that the issue can be resolved by modifying therender method to correctly identify and use the appropriate serializer based on the object instance during the rendering process. This adjustment should enableincludes to function as expected with polymorphic serializers.

if serializer is not None:    # Extract root meta for any type of serializer    json_api_meta.update(self.extract_root_meta(serializer, serializer_data))    if getattr(serializer, "many", False):        ...    else:        if isinstance(serializer, PolymorphicModelSerializer):            resource_instance = serializer.instance            serializer_class = serializer.get_polymorphic_serializer_for_instance(resource_instance)            serializer = serializer_class(resource_instance, context=serializer.context)            fields = utils.get_serializer_fields(serializer)            ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp