Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upImprove ChoiceField.choices documentation #7246
Comments
|
You can find choice values and display values in the response from I would say that serializing choice field values to If your particular use-case requires |
|
@denolehov is correct. The I've gone into more detail in #6854 (comment), but in short, it would be nice if there was some construct that differentiated DB values, API representation, and display values. |


Hi,
i just now stumbled upon that the
ChoiceFieldaccepts the choices as tuples(value, display_name)like documented here. As in this issue #4082, i was very surprised that the representation is thevaluenot thedisplay_nameprovided in the choices.So:
I'd expect the
display_nameas the representation for a givenvaluewhy else should i define thedisplay_namethen? The issue mentioned above was briefly answered with a quote form the django docs which, in my eyes, would point towards my expected behavior.Especially if your API serves a detached frontend app. This app would need the choices-dict too for the correct display of the possible abstract values. Thus leading to code duplication.