I\'m trying to format numbers. Examples:
1 => 1
12 => 12
123 => 123
1234 => 1,234
12345 => 12,345
It strikes as a
Based on muhuk answer I did this simple tag encapsulating python string.format
method.
templatetags
at your's application folder. format.py
file on it.Add this to it:
from django import template
register = template.Library()
@register.filter(name='format')
def format(value, fmt):
return fmt.format(value)
{% load format %}
{{ some_value|format:"{:0.2f}" }}