mirror of
				https://github.com/django/django.git
				synced 2025-11-04 05:35:37 +00:00 
			
		
		
		
	Fixed #11783 -- ordinal template tag now catches TypeError. Thanks, realpolitik and punteney
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12199 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		
							parent
							
								
									a4b0947a92
								
							
						
					
					
						commit
						8b9cf79ff6
					
				
					 2 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -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
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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')
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue