I’m trying to simply render a size in bytes to a string which describes it in human-readable format:
$ python -c "import jinja2 ; print jinja2.Template(\"{{ bytes|filesizeformat }}\").render(bytes=1572864)"
0.0 MB
Unfortunately, I always get 0.0 MB as the result. Why am I not getting a real value?
The
filesizeformatfilter was fixed in version 2.7The fix, however, is really simple, involves only two lines of code, and you can implement it yourself. See here.