I try to implement enumartion structure in django such that
class Status():
PENDING = 0
CONFIRMED = 1
DENIED = 2
STATUS =(
(PENDING,_("salary_status_pending")),
(CONFIRMED,_("salary_status_confirmed")),
(DENIED,_("salary_status_denied")),
)
and in my model I use it like
class MyModel(models.Model):
status = models.IntegerField(null=False, choices=Status.STATUS)
It works fine and if I want to get the label of enum field in my template I use
{{ mymodel.get_status_display }} and it writes the label _('key..') in my enum field instead of number which is explained in Django documents
However, what if I want to get the label in my view.py ?
I want to write a code below and it should give me the label of enum field instead of number
Status.CONFIRMED
How can I achive this ?
Thanks
I found it.The code below does what I want