Hi,
i just now stumbled upon that the ChoiceField accepts the choices as tuples (value, display_name) like documented here. As in this issue #4082, i was very surprised that the representation is the value not the display_nameprovided in the choices.
So:
- It would be nice to document this explicitly.
- Why is the behavior defined this way?
I'd expect the display_name as the representation for a given value why else should i define the display_name then? 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.
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.