#31262: Document and explicitly support dictionaries being passed to field 
choices
---------------------------------------+------------------------
               Reporter:  Tom Forbes   |          Owner:  nobody
                   Type:  New feature  |         Status:  new
              Component:  Forms        |        Version:
               Severity:  Normal       |       Keywords:
           Triage Stage:  Unreviewed   |      Has patch:  0
    Needs documentation:  0            |    Needs tests:  0
Patch needs improvement:  0            |  Easy pickings:  1
                  UI/UX:  0            |
---------------------------------------+------------------------
 The Django documentation gives this example for creating named groups of
 choices:


 {{{
 MEDIA_CHOICES = [
     ('Audio', (
             ('vinyl', 'Vinyl'),
             ('cd', 'CD'),
         )
     ),
     ('Video', (
             ('vhs', 'VHS Tape'),
             ('dvd', 'DVD'),
         )
     ),
     ('unknown', 'Unknown'),
 ]
 }}}

 With Python 3.7 (and implicitly in CPython 3.6) dictionaries are ordered,
 meaning this syntax could be replaced by the cleaner and easier to parse:

 {{{
 {
     "Audio": (
          ('vinyl', 'Vinyl'),
          ('cd', 'CD'),
     ),
     "Video": (
         ('vhs', 'VHS Tape'),
         ('dvd', 'DVD'),
     ),
    "unknown": "Unknown"
 }
 }}}

 Once 3.7 is the lowest supported version we should document that this is
 supported, and ensure that it works correctly.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31262>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/046.d065c1422a0af9e8bf146e84da2aab98%40djangoproject.com.

Reply via email to