#35562: get_FOO_display() method gives choice instead of choice.label for unbound
(not saved) model instances with enumeration choices
-------------------------------------+-------------------------------------
Reporter: Gerben | Owner: nobody
Morsink |
Type: Bug | Status: new
Component: Database | Version: 4.2
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
{{{
class FooChoices(models.TextChoices):
BAR = 'BAR', 'bar_with_drinks'
foo = Foo(bar=FooChoices.BAR)
foo.get_bar_display() -> I expect it to return 'bar_with_drinks'
(=FooChoices.BAR.label), but it returns a 'FooChoices.BAR' object.
}}}
This is opposed to when I get Foo out of the database, because then
foo.get_bar_display() will return the FooChoices.BAR.label.
--
Ticket URL: <
https://code.djangoproject.com/ticket/35562>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.