Ticket #8462: length_invalid_usage_8462.diff

File length_invalid_usage_8462.diff, 761 bytes (added by marcelor, 6 years ago)

Fixed bad syntax.

  • django/template/defaultfilters.py

     
    507507
    508508def length(value):
    509509    """Returns the length of the value - useful for lists."""
    510     return len(value)
     510    try:
     511        return len(value)
     512    except (ValueError,TypeError):
     513        return ''
    511514length.is_safe = True
    512515
    513516def length_is(value, arg):
    514517    """Returns a boolean of whether the value's length is the argument."""
    515     return len(value) == int(arg)
     518    try:
     519        return len(value) == int(arg)
     520    except (ValueError,TypeError):
     521        return ''
    516522length_is.is_safe = False
    517523
    518524def random(value):
Back to Top