@register.filter(is_safe=True)
def length(value):
 try:
  return len(value)
 except (ValueError, TypeError):
  return u''

@ register . filter ( is_safe = True ) def length ( value ) : try : return len ( value ) except ( ValueError , TypeError ) : return u''
return whether or not the length of given string is within a specified range .