#4092: django/contrib/localflavor/usa/forms.py USStateSelect missing blank
options
-----------------------------------------+----------------------------------
Reporter: polpak <[EMAIL PROTECTED]> | Owner: nobody
Status: new | Component:
django.contrib.localflavor
Version: SVN | Resolution:
Keywords: | Stage: Accepted
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-----------------------------------------+----------------------------------
Comment (by dougn):
I was looking at this and there are 20 Select widgets which would need to
be changed.
It feels like there should be a new base widget which deals with the empty
choice (The same way there is for the !ModelChoiceField.
I could just be over thinking things and making them more complex than
necessary.
{{{
#!python
from itertools import chain
class NullSelect(Select):
def __init__(self, attrs=None, choices=(), empty_label=u"---------"):
empty_choice = ((u'', empty_label),)
super(NullSelect, self).__init__(attrs, chain(empty_choice,
choices))
}}}
With this addition, the newforms.models.!ModelChoiceField would no longer
need the empty_label,
and would use the newforms.widgets.!NullSelect widget instead.
--
Ticket URL: <http://code.djangoproject.com/ticket/4092#comment:4>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---