summaryrefslogtreecommitdiff
path: root/django/forms/fields.py
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2009-06-01 15:38:11 +0000
committerHonza Král <honza.kral@gmail.com>2009-06-01 15:38:11 +0000
commit55e23d5efaa11b7385c9c0d117378b07cdeb7341 (patch)
tree3f256f30b15ca2212bb248bf06d484fa73481aa3 /django/forms/fields.py
parenta2b215263596b1778054e3e8710dd6da13063f16 (diff)
[soc2009/model-validation] Moved ValidationError to django.core.exceptions and removed ErrorList from within the Error
git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/model-validation@10867 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/fields.py')
-rw-r--r--django/forms/fields.py17
1 files changed, 6 insertions, 11 deletions
diff --git a/django/forms/fields.py b/django/forms/fields.py
index affe3879b9..3e32d8a6f4 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -23,12 +23,14 @@ try:
except NameError:
from sets import Set as set
-import django.core.exceptions
+from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode, smart_str
-from util import ErrorList, ValidationError
-from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget
+from util import ErrorList
+from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, \
+ FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, \
+ DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget
from django.core.files.uploadedfile import SimpleUploadedFile as UploadedFile
__all__ = (
@@ -683,16 +685,9 @@ class TypedChoiceField(ChoiceField):
value = super(TypedChoiceField, self).clean(value)
if value == self.empty_value or value in EMPTY_VALUES:
return self.empty_value
-
- # Hack alert: This field is purpose-made to use with Field.to_python as
- # a coercion function so that ModelForms with choices work. However,
- # Django's Field.to_python raises
- # django.core.exceptions.ValidationError, which is a *different*
- # exception than django.forms.util.ValidationError. So we need to catch
- # both.
try:
value = self.coerce(value)
- except (ValueError, TypeError, django.core.exceptions.ValidationError):
+ except (ValueError, TypeError, ValidationError):
raise ValidationError(self.error_messages['invalid_choice'] % {'value': value})
return value