Skip to content

Serializer validation. Issue with parsing dictionary if array is a value #3598

@akolpakov

Description

@akolpakov

At this line function parse_html_dict allow to parse dictionaries with primitive values like:

    {
        'profile.username': 'example',
        'profile.email': 'example@example.com',
    }
        -->
    {
        'profile': {
            'username': 'example',
            'email': 'example@example.com'
        }
    }

But if value is an array parser does not work properly:

    {
        'profile.username': 'example',
        'profile.email': 'example@example.com',
        'profile.group': ['1', '2'],
    }

Problem that QueryDict on the line:

for field, value in dictionary.items():

dictionary.items() returns last item from list ['1', '2'] as a value.

I have the following Serializer:

class ProfileSerializer(serializers.ModelSerializer):
    class Meta:
        model = Profile

class UserSerializer(serializers.ModelSerializer):
    profile = ProfileSerializer(required=False)

and group is a ManyToMany field in Profile model.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy