Rename ChoiceField "label" field to "display_name" in REST API #3472

Closed
opened 2025-12-29 18:29:24 +01:00 by adam · 3 comments
Owner

Originally created by @jeremystretch on GitHub (Mar 12, 2020).

Environment

  • Python version: 3.6.9
  • NetBox version: 2.7.10

Proposed Functionality

The representation of a ChoiceField value in the REST API looks like this:

"status": {
    "value": "active",
    "label": "Active",
},

The value field indicates the "raw" database value, and the label field conveys a human-friendly string for display to the user. This issue proposes renaming the label field to display_name:

"status": {
    "value": "active",
    "display_name": "Active",
},

If approved, we'll continue to send both the label and display_name fields with equivalent values for at least the duration of the NetBox v2.8 release to maintain backward-compatibility.

Use Case

display_name is more canonical to Django, and OpenAPI introspection already assumes (incorrectly) that a display_name field is present in choice representations.

Database Changes

None

External Dependencies

None

Originally created by @jeremystretch on GitHub (Mar 12, 2020). ### Environment * Python version: 3.6.9 * NetBox version: 2.7.10 ### Proposed Functionality The representation of a ChoiceField value in the REST API looks like this: ```json "status": { "value": "active", "label": "Active", }, ``` The `value` field indicates the "raw" database value, and the `label` field conveys a human-friendly string for display to the user. This issue proposes renaming the `label` field to `display_name`: ```json "status": { "value": "active", "display_name": "Active", }, ``` If approved, we'll continue to send both the `label` and `display_name` fields with equivalent values for at least the duration of the NetBox v2.8 release to maintain backward-compatibility. ### Use Case `display_name` is more canonical to Django, and OpenAPI introspection already assumes (incorrectly) that a `display_name` field is present in choice representations. ### Database Changes None ### External Dependencies None
adam added the status: under review label 2025-12-29 18:29:24 +01:00
adam closed this issue 2025-12-29 18:29:24 +01:00
Author
Owner

@dstarner commented on GitHub (Mar 13, 2020):

Don't the new enumeration types use label though? Isn't this becoming more of a standard? I feel like either way is fine, since display_name is the older way and label is the newer way.

@dstarner commented on GitHub (Mar 13, 2020): Don't the new enumeration types use `label` though? Isn't this becoming more of a standard? I feel like either way is fine, since `display_name` is the older way and `label` is the newer way.
Author
Owner

@jeremystretch commented on GitHub (Mar 14, 2020):

If that's the case I'm happy to stick with label, just want to the introspection to be consistent.

@jeremystretch commented on GitHub (Mar 14, 2020): If that's the case I'm happy to stick with `label`, just want to the introspection to be consistent.
Author
Owner

@jeremystretch commented on GitHub (Mar 18, 2020):

We'll stick with label.

@jeremystretch commented on GitHub (Mar 18, 2020): We'll stick with `label`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3472