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

List serializer bug with only one object passed #4606

Closed
Labels
Milestone
@yelsherbini

Description

@yelsherbini

There is a bug when validating only one object with a list serializer with raise_exception flag set as True.

It worked just fine in 3.4.7.

Steps to reproduce

Here is the class that will cause the issue

class TheSerializer(serializers.Serializer):    name = serializers.CharField(required=True)    choices = serializers.CharField(required=True)

Then run

    serializer = TheSerializer(data=[{"name": "hhj"}], many=True)    serializer.is_valid(raise_exception=True)

Expected behavior

        if self._errors and raise_exception:>           raise ValidationError(self.errors)E           rest_framework.exceptions.ValidationError: [{'choices': ['This field is required.']}]

Actual behavior

self = TheSerializer(data=[{'name': 'hhj'}], many=True):    name = CharField(required=True)    choices = CharField(required=True)    @property    def errors(self):        ret = super(ListSerializer, self).errors>       if isinstance(ret, list) and len(ret) == 1 and ret[0].code == 'null':E       AttributeError: 'dict' object has no attribute 'code'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp