You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pint has special string formatting support. For example, from the docs:
>>> accel = 1.3 * ureg['meter/second**2']
>>> 'The HTML representation is {:H}'.format(accel)
'The HTML representation is 1.3 meter/second<sup>2</sup>'
I added this file as myapp/templatetags/pint_fmt.py:
And it gives me my field with two decimal places, and renders the units in HTML.
I haven't thought through the security implications of the mark_safe (my web site will be used by only me), and I don't know if you like the details of this way of getting at the formatting code, but I thought you might want to think about it.
Thanks for django-pint, it's great - exactly what I needed!
The text was updated successfully, but these errors were encountered:
Pint has special string formatting support. For example, from the docs:
I added this file as
myapp/templatetags/pint_fmt.py
:Now I can do this in my templates:
And it gives me my field with two decimal places, and renders the units in HTML.
I haven't thought through the security implications of the mark_safe (my web site will be used by only me), and I don't know if you like the details of this way of getting at the formatting code, but I thought you might want to think about it.
Thanks for django-pint, it's great - exactly what I needed!
The text was updated successfully, but these errors were encountered: