--
Ticket URL: <https://code.djangoproject.com/ticket/33186>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* resolution: => invalid
* easy: 1 => 0
Comment:
> I think it would be nice if the docs explicitly mentioned that
get_FOO_display returns name, not the label if you were to use
models.IntegerChoices or models.TextChoices.
As far as I'm aware `get_FOO_display()` returns labels as expected:
{{{
class YearInSchool(models.TextChoices):
FRESHMAN = 'FR', 'Freshman'
SOPHOMORE = 'SO', 'Sophomore'
JUNIOR = 'JR', 'Junior'
SENIOR = 'SR', 'Senior'
GRADUATE = 'GR', 'Graduate'
class MyModel(models.Model):
foo = models.CharField(max_length=254, choices=YearInSchool.choices)
>>> MyModel(foo='FR').get_foo_display())
Freshman
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/33186#comment:1>