Skip to content

Maybe there is something wrong in ChoiceField. #4082

@jz0630

Description

@jz0630

Steps to reproduce

My code just like this.

MY_CHOICES = (
    (0, 'happy'),
    (1, 'sad')
)
serializers.ChoiceField(MY_CHOICES)

Expected behavior

When the value of the field is 0, I expect the representation is 'happy'.

Actual behavior

It's representation 0 instead.

When I change the code of ChoiceField, it well be right. The diff of the change is https://github.com/jz0630/django-rest-framework/commit/958033ad878f3eb0d0dcbe45dd35c7a4bda53654

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