Skip to content

Improve ChoiceField.choices documentation #7246

Description

@chgad

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:

  1. It would be nice to document this explicitly.
  2. 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.

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