#27239: Unexpected behavior on get_FIELDNAME_display when as int as value ----------------------------------------------+--------------------------- Reporter: levivm | Owner: nobody Type: Bug | Status: new Component: Database layer (models, ORM) | Version: 1.10 Severity: Normal | Keywords: choice, field Triage Stage: Unreviewed | Has patch: 0 Easy pickings: 0 | UI/UX: 0 ----------------------------------------------+--------------------------- Let's say we have have a choice field called gender and it has intengers as values.
{{{ GENDER_CHOICES = ( (1, _('Male')), (2, _('Female')) ) gender = models.CharField(choices=GENDER_CHOICES, null=True) }}} If we create an instance with a gender as 1 or '1' and then try to display gender field value using get_FIELDNAME_display method, we will get unwanted value. We will get '1' and not 'Male' as it supposed to be. {{{ Model.instance.create(gender=1) instance.get_gender_display() >>>'1' }}} The correct response should be {{{ Model.instance.create(gender=1) instance.get_gender_display() >>>'Male' }}} -- Ticket URL: <https://code.djangoproject.com/ticket/27239> 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 post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/049.18626222b0ea95a4d70705aaa5ff02a9%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.