﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23128	_get_FIELD_display doesn't work with Field.get_choices using Iterators	Areski Belaid	Sergii Lapin	"'''Context:''' 
This issue has been noted when fixing https://code.djangoproject.com/ticket/23112


'''Current behavior:'''
Using _get_FIELD_display on a Field.choices using Iterators, you will get the first tuple value.


'''Expected behavior:'''
Expected result is to get the human-readable name in from the iterator tuple.


'''Tests to reproduce the issue:'''

Edit `tests/model_fields/tests.py` add inside `class ChoicesTests(test.TestCase)` the following tests:
{{{
def test_iterator_choices_and_field_display(self):
    """"""
    Check that get_choices works with Iterators (#23112).
    """"""
    self.assertEqual(WhizIter(c=1).get_c_display(), 'val-1') # A nested value
    self.assertEqual(WhizIter(c=9).get_c_display(), 9) # Invalid value
    self.assertEqual(WhizIter(c=None).get_c_display(), None) # Blank value
    self.assertEqual(WhizIter(c='').get_c_display(), '') # Empty value
}}}"	Bug	closed	Database layer (models, ORM)	dev	Normal	worksforme	get_choices	cmawebsite@…	Accepted	0	0	0	0	0	0
