What I (think I) want is, given like a ChoiceField like so:
class FoodSerializer(serializers.Serializer):
food_choices = (('pasta','Delicious Pasta'), ('pizza', 'Big pizza'))
food = ChoiceField(choices=food_choices)
That would serialize to:
{
'food': {
'value': 'pasta',
'display_value': 'Delicious Pasta',
}
}
, and, respectively, should be able to deserialize the following to match the above:
{
'food': 'pasta',
}
or
{
'food': {
'value': 'pasta',
'display_value': 'Delicious Pasta',
}
}
Does anyone know of a python package that will do that? Otherwise, I may write it myself.