'DRF Choice Field Says Human-Readable Value is Invalid

I have a serializer with a choices field named locations with a list of tuples containing the 2 letter key and the full name value

// Ex:  ('CA', 'California')

class SomeSerializer(serializers.Serializer):
    location = serializers.ChoiceField(choices=US_STATES)

When I pass in "California", through API, the serializer throws the invalid_choice error. However, it works when I pass in "CA".

How do I make it so the serializer is able to read "California" as a choice instead of "CA"?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source