diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py index 05d322363b..3e19fed823 100644 --- a/django/contrib/humanize/templatetags/humanize.py +++ b/django/contrib/humanize/templatetags/humanize.py @@ -14,7 +14,7 @@ def ordinal(value): """ try: value = int(value) - except ValueError: + except (TypeError, ValueError): return value t = (_('th'), _('st'), _('nd'), _('rd'), _('th'), _('th'), _('th'), _('th'), _('th'), _('th')) if value % 100 in (11, 12, 13): # special case diff --git a/tests/regressiontests/humanize/tests.py b/tests/regressiontests/humanize/tests.py index 6f60c6d6f9..8b454719a1 100644 --- a/tests/regressiontests/humanize/tests.py +++ b/tests/regressiontests/humanize/tests.py @@ -22,10 +22,10 @@ class HumanizeTests(unittest.TestCase): def test_ordinal(self): test_list = ('1','2','3','4','11','12', '13','101','102','103','111', - 'something else') + 'something else', None) result_list = ('1st', '2nd', '3rd', '4th', '11th', '12th', '13th', '101st', '102nd', '103rd', - '111th', 'something else') + '111th', 'something else', None) self.humanize_tester(test_list, result_list, 'ordinal')