#29247: Fix choices ignoring the defined blank value
--------------------------------------+-------------------------
               Reporter:  orlnub123   |          Owner:  nobody
                   Type:  Bug         |         Status:  new
              Component:  Forms       |        Version:  master
               Severity:  Normal      |       Keywords:  choices
           Triage Stage:  Unreviewed  |      Has patch:  1
    Needs documentation:  0           |    Needs tests:  0
Patch needs improvement:  0           |  Easy pickings:  0
                  UI/UX:  0           |
--------------------------------------+-------------------------
 While sifting through the source code to understand the internals for a
 package I'm making, I stumbled upon what looked like a bug.

 These lines right here:
 {{{
 named_groups = isinstance(choices[0][1], (list, tuple))
 blank_defined = not named_groups and any(choice in ('', None) for choice,
 __ in choices)
 }}}
 And indeed a bug it was.

 The problem was that, had you defined your choices first with a group and
 then later on a choice that defined the blank value, the current
 implementation would skip right over it! So you would end up with having
 both the default blank value and the one you've defined, which doesn't
 look very pretty.

 I've created a pull request on github that fixes the issue
 [https://github.com/django/django/pull/9813 here.]

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29247>
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/052.3bf6cc183c30c730a2dc73d0fb2d0621%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to