Opened 17 months ago
Last modified 17 months ago
#35562 closed Bug
get_FOO_display() method gives choice instead of choice.label for unbound (not saved) model instances with enumeration choices — at Version 1
| Reported by: | Gerben Morsink | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | 4.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
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.
Note:
See TracTickets
for help on using tickets.