Tuesday, November 10, 2009

forms.ChoiceField and empty values

Hi,

I have the following problem... I've got a form, which looks like
this:

class CompetitionSearchForm(forms.Form):
name = forms.CharField(required=False)
type = forms.ChoiceField(choices=COMPETITION_TYPE_CHOICES,
required=False)

The tuple COMPETITION_TYPE_CHOICES is used in a model class (the
purpose of the form is to search through Competition objects). It
looks something a bit like this:

COMPETITION_TYPE_CHOICES = (
(1, 'Olympic Games'),
(2, 'ISU Championships'),
(3, 'Grand Prix Series'),
)

I'd like the select widget in ChoiceField to display an empty label.
According to the documentation (http://docs.djangoproject.com/en/dev/
ref/forms/fields/#choicefield
), it seems like this should happen by
default, but I don't get an empty value in the select widget at all.
Why is this?

Monika
--~--~---------~--~----~------------~-------~--~----~
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 django-users+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate