Kolleno provides a powerful smart fields module that makes numbers and dates more readable by formatting them in a user-friendly way. This guide will walk you through its key features with practical examples.
1. intcomma
Inserts commas as thousands separators in large numbers.
Example:
{{ 1234567|intcomma }}
Output:
1,234,567
2. intword
Converts large numbers into a readable format using words like “million” or “billion.”
Example:
{{ 1500000|intword }}
Output:
1.5 million
3. naturalday
Formats dates relative to today (e.g., “yesterday,” “today”).
Example:
{{ some_date|naturalday }}
Possible Outputs:
Today’s date →
today
Yesterday’s date →
yesterday
Any other date →
Month Day, Year
4. naturaltime
Formats timestamps relative to now (e.g., “3 hours ago”).
Example:
{{ some_datetime|naturaltime }}
Possible Outputs:
5 minutes ago →
5 minutes ago
2 days ago →
2 days ago
3 hours from now →
3 hours from now
5. ordinal
Adds ordinal suffixes to numbers (e.g., 1st
, 2nd
, 3rd
).
Example:
{{ 21|ordinal }}
Output:
21st
6. apnumber
Converts numbers 1-9 into their word representation.
Example:
{{ 7|apnumber }}
Output:
seven
7. floatformat
Formats floating-point numbers to a specified number of decimal places.
Example:
{{ 1234.5678|floatformat:2 }}
Output:
1234.57
Combining Filters
You can combine multiple filters for more refined formatting.
Example:
{{ 1234567.891|floatformat:2|intcomma }}
Output:
1,234,567.89
Conclusion
Kolleno's smart fields enhance readability by making numbers and dates more user-friendly. Whether displaying financial data, timestamps, or rankings, these filters simplify formatting while maintaining clarity.