Hello,

I'm trying to extend the Select widget to only display the field if
more than one choice is available. How can I check the available
choices in the __init__() when I'm extending the SelectWidget :

class OptionalSelect(forms.Select):
    def __init__(self, attrs=None, choices=()):
        super(OptionalSelect, self).__init__(attrs)
        self.choices = list(choices)
        if len(list(self.choices)) <= 2:
            self.is_hidden = True

But choices don't seems to be populated by the ModelChoiceField.

I'll take any help.

-- 
Fabien SCHWOB
_____________________________________________________________
Derrière chaque bogue, il y a un développeur, un homme qui s'est trompé.
(Bon, OK, parfois ils s'y mettent à plusieurs).

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to