Django

Code

Ticket #2489: capfirst.diff

File capfirst.diff, 0.7 kB (added by nesh <nesh [at] studioquattro [dot] co [dot] yu>, 2 years ago)

small fix for capfirst filter to enable unicode strings

  • /www-libs/django/django/template/defaultfilters.py

    old new  
    1919 
    2020def capfirst(value): 
    2121    "Capitalizes the first character of the value" 
    22     value = str(value) 
     22    if isinstance(value, str): 
     23        # convert to unicode string 
     24        value = unicode(value, settings.DEFAULT_CHARSET) 
     25    elif not isinstance(value, basestring): 
     26        value = unicode(value) 
    2327    return value and value[0].upper() + value[1:] 
    2428 
    2529def fix_ampersands(value):