Ticket #2914: 2914.diff

File 2914.diff, 589 bytes (added by dev@…, 18 years ago)
  • django/template/defaultfilters.py

     
    421421    Format the value like a 'human-readable' file size (i.e. 13 KB, 4.1 MB, 102
    422422    bytes, etc).
    423423    """
    424     bytes = float(bytes)
     424    try:
     425        bytes = float(bytes)
     426    except TypeError:
     427        return "0 bytes"
     428       
    425429    if bytes < 1024:
    426430        return "%d byte%s" % (bytes, bytes != 1 and 's' or '')
    427431    if bytes < 1024 * 1024:
Back to Top