diff -r 3f91fa6ba472 db/models/fields/__init__.py --- a/db/models/fields/__init__.py Wed Jul 07 17:22:15 2010 -0400 +++ b/db/models/fields/__init__.py Wed Oct 06 12:41:37 2010 -0400 @@ -168,15 +168,25 @@ # Skip validation for non-editable fields. return if self._choices and value: + choices_dict = dict() for option_key, option_value in self.choices: if isinstance(option_value, (list, tuple)): # This is an optgroup, so look inside the group for options. for optgroup_key, optgroup_value in option_value: - if value == optgroup_key: - return - elif value == option_key: - return - raise exceptions.ValidationError(self.error_messages['invalid_choice'] % value) + choices_dict.update({optgroup_key : optgroup_value}) + else: + choices_dict.update({option_key : option_value}) + _value = value + if not isinstance(value, (list, tuple)): + _value = [value] + invalid_v = [] + for v in _value: + if not choices_dict.has_key(v): + invalid_v.append(v) + if invalid_v.__len__() > 0: + raise exceptions.ValidationError(self.error_messages['invalid_choice'] % invalid_v) + else: + return if value is None and not self.null: raise exceptions.ValidationError(self.error_messages['null'])