Permalink
Browse files

is_select looks for ChoiceField rather than Select widget.

  • Loading branch information...
1 parent ea255b3 commit 1e4d809b04eb4bf11ebca419d861e3c1c8f2406f @carljm committed Jan 24, 2013
Showing with 4 additions and 5 deletions.
  1. +2 −3 form_utils/templatetags/form_utils.py
  2. +2 −2 tests/tests.py
@@ -98,8 +98,7 @@ def is_multiple(boundfield):
return isinstance(boundfield.field, forms.MultipleChoiceField)
-
@register.filter
def is_select(boundfield):
- """Return True if this field's widget is a Select (or subclass)."""
- return isinstance(boundfield.field.widget, forms.Select)
+ """Return True if this field is a ChoiceField (or subclass)."""
+ return isinstance(boundfield.field, forms.ChoiceField)
View
@@ -793,14 +793,14 @@ def test_is_not_multiple(self):
def test_is_select(self):
- """`is_select` detects a Select."""
+ """`is_select` detects a ChoiceField."""
f = self.form()
self.assertTrue(self.form_utils.is_select(f["level"]))
def test_is_not_select(self):
- """`is_select` detects a non-select widget."""
+ """`is_select` detects a non-ChoiceField."""
f = self.form()
self.assertFalse(self.form_utils.is_select(f["name"]))

0 comments on commit 1e4d809

Please sign in to comment.