0

I'm using option group-style choices for a django form field, like this:

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

This works fine so long as the widget I am using is the default forms.widgets.Select. However, when I try to use forms.widget.SelectMultiple I get the following error message:

Select a valid choice. [u'vhs', u'dvd'] is not one of the available choices.
Jordan Reiter
  • 20,467
  • 11
  • 95
  • 161

1 Answers1

2

Changing the widget doesn't change the type of data accepted by a field. A normal ChoiceField still only expects a single value. If you want to accept more than one value, you need to use MultipleChoiceField.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895