Ticket #7100: defaultfilters.diff
File defaultfilters.diff, 1.2 KB (added by , 17 years ago) |
---|
-
django/template/defaultfilters.py
10 10 from django.template import Variable, Library 11 11 from django.conf import settings 12 12 from django.utils.translation import ugettext, ungettext 13 from django.utils.encoding import force_unicode, iri_to_uri 13 from django.utils.encoding import force_unicode, iri_to_uri,smart_str 14 14 from django.utils.safestring import mark_safe, SafeData 15 15 16 16 register = Library() … … 28 28 def _dec(*args, **kwargs): 29 29 if args: 30 30 args = list(args) 31 if getattr(func, 'to_str', False): 32 args[0] = smart_str(args[0]) 31 33 args[0] = force_unicode(args[0]) 32 34 if isinstance(args[0], SafeData) and getattr(func, 'is_safe', False): 33 35 return mark_safe(func(*args, **kwargs)) … … 223 225 return value # Fail silently. 224 226 return truncate_words(value, length) 225 227 truncatewords.is_safe = True 228 truncatewords.to_str = True 226 229 truncatewords = stringfilter(truncatewords) 227 230 228 231 def truncatewords_html(value, arg):