Skip to content

Commit

Permalink
[1.0.X] Fixed #9384 -- Fixed a couple of typos. Thanks, Thomas Güttle…
Browse files Browse the repository at this point in the history
…r and romke.

Backport of r9255 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9259 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Oct 24, 2008
1 parent 6c85612 commit 73ea785
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions django/forms/fields.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ def __init__(self, *args, **kwargs):
self.coerce = kwargs.pop('coerce', lambda val: val) self.coerce = kwargs.pop('coerce', lambda val: val)
self.empty_value = kwargs.pop('empty_value', '') self.empty_value = kwargs.pop('empty_value', '')
super(TypedChoiceField, self).__init__(*args, **kwargs) super(TypedChoiceField, self).__init__(*args, **kwargs)

def clean(self, value): def clean(self, value):
""" """
Validate that the value is in self.choices and can be coerced to the Validate that the value is in self.choices and can be coerced to the
Expand All @@ -676,12 +676,12 @@ def clean(self, value):
value = super(TypedChoiceField, self).clean(value) value = super(TypedChoiceField, self).clean(value)
if value == self.empty_value or value in EMPTY_VALUES: if value == self.empty_value or value in EMPTY_VALUES:
return self.empty_value return self.empty_value

# Hack alert: This field is purpose-made to use with Field.to_python as # Hack alert: This field is purpose-made to use with Field.to_python as
# a coercion function so that ModelForms with choices work. However, # a coercion function so that ModelForms with choices work. However,
# Django's Field.to_python raises django.core.exceptions.ValidationError, # Django's Field.to_python raises
# which is a *different* exception than # django.core.exceptions.ValidationError, which is a *different*
# django.forms.utils.ValidationError. So unfortunatly we need to catch # exception than django.forms.util.ValidationError. So we need to catch
# both. # both.
try: try:
value = self.coerce(value) value = self.coerce(value)
Expand Down
4 changes: 2 additions & 2 deletions docs/ref/forms/validation.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ through the ``Form.non_field_errors()`` method.


When you really do need to attach the error to a particular field, you should When you really do need to attach the error to a particular field, you should
store (or amend) a key in the `Form._errors` attribute. This attribute is an store (or amend) a key in the `Form._errors` attribute. This attribute is an
instance of a ``django.form.utils.ErrorDict`` class. Essentially, though, it's instance of a ``django.forms.util.ErrorDict`` class. Essentially, though, it's
just a dictionary. There is a key in the dictionary for each field in the form just a dictionary. There is a key in the dictionary for each field in the form
that has an error. Each value in the dictionary is a that has an error. Each value in the dictionary is a
``django.form.utils.ErrorList`` instance, which is a list that knows how to ``django.forms.util.ErrorList`` instance, which is a list that knows how to
display itself in different ways. So you can treat `_errors` as a dictionary display itself in different ways. So you can treat `_errors` as a dictionary
mapping field names to lists. mapping field names to lists.


Expand Down

0 comments on commit 73ea785

Please sign in to comment.