#23128: _get_FIELD_display doesn't work with Field.get_choices using Iterators
----------------------------------------------+-------------------------
     Reporter:  areski                        |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  master
     Severity:  Normal                        |   Keywords:  get_choices
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+-------------------------
 '''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

-- 
Ticket URL: <https://code.djangoproject.com/ticket/23128>
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.d7f12bd7ba6302109e25dc8a8335c996%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to