#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107019050dc91a2-e6502d3f-0645-42f3-a4fd-fc1809c2c49e-000000%40eu-central-1.amazonses.com.

Reply via email to