module documentation

Undocumented

Variable intword​_converters Undocumented
Variable register Undocumented
Class ​Natural​Time​Formatter Undocumented
Function apnumber For numbers 1-9, return the number spelled out. Otherwise, return the number. This follows Associated Press style.
Function intcomma Convert an integer to a string containing commas every three digits. For example, 3000 becomes '3,000' and 45000 becomes '45,000'.
Function intword Convert a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
Function naturalday For date values that are tomorrow, today or yesterday compared to present day return representing string. Otherwise, return a string formatted according to settings.DATE_FORMAT.
Function naturaltime For date and time values show how many seconds, minutes, or hours ago compared to current timestamp return representing string.
Function ordinal Convert an integer to its ordinal as a string. 1 is '1st', 2 is '2nd', 3 is '3rd', etc. Works for any integer.
intword_converters =

Undocumented

register =

Undocumented

@register.filter(is_safe=True)
def apnumber(value):
For numbers 1-9, return the number spelled out. Otherwise, return the number. This follows Associated Press style.
@register.filter(is_safe=True)
def intcomma(value, use_l10n=True):
Convert an integer to a string containing commas every three digits. For example, 3000 becomes '3,000' and 45000 becomes '45,000'.
@register.filter(is_safe=False)
def intword(value):
Convert a large integer to a friendly text representation. Works best for numbers over 1 million. For example, 1000000 becomes '1.0 million', 1200000 becomes '1.2 million' and '1200000000' becomes '1.2 billion'.
@register.filter(expects_localtime=True)
def naturalday(value, arg=None):
For date values that are tomorrow, today or yesterday compared to present day return representing string. Otherwise, return a string formatted according to settings.DATE_FORMAT.
@register.filter
def naturaltime(value):
For date and time values show how many seconds, minutes, or hours ago compared to current timestamp return representing string.
@register.filter(is_safe=True)
def ordinal(value):
Convert an integer to its ordinal as a string. 1 is '1st', 2 is '2nd', 3 is '3rd', etc. Works for any integer.