Skip to content

Is there a way to get the status label value of an item in a script #17179

Answered by zmaster7
atownson asked this question in Help Wanted!
Discussion options

You must be logged in to vote

It looks like each model with the status field has a get_status_display() option, which will return the label for the status it has, e.g:

Device.objects.first().get_status_display()

In addition to get_status_display(), get_status_color() is another option.

On a side note, utilizing nbshell can be helpful to determine what options are available for a given model.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by atownson
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants