I would like something similar to the string formatting from the standard library.
'%' Percentage. Multiplies the number by 100 and displays in fixed ('f') format, followed by a percent sign.
I would like something similar to the string formatting from the standard library.
'%' Percentage. Multiplies the number by 100 and displays in fixed ('f') format, followed by a percent sign.
The newness of string.Formatter()
means that Django is not likely to support it built-in. Either write or find a template tag or filter that implements it.
In case somebody is looking for the answser, this is how I solved the problem with a custom templatetag:
from django import template
register = template.Library()
@register.filter
def percentage(decimal):
return format(decimal, "%")