On Thursday, February 10, 2011 3:46:01 PM UTC, refreegrata wrote:
>
> Hello list, I have a question. I want to assign the size of a file to 
> a var in the view, but the value must to be formated in a human- 
> readable file size. This is for a PDF report. In a template I can be 
> used the filter "filesizeformat", but Are some way to use that filter 
> in a view? 
>
> Thanks for read, and sorry for my poor english.


Yes, you can just import it and use it like any other function:

>>> from django.template.defaultfilters import filesizeformat
>>> filesizeformat(123123123)
u'117.4 MB'
 
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to