0

how to get the file size of a video which is in file system using filesizeformat of django?

    `{{ db.vid|filesizeformat }}` 
     returns only the size of the path.
raj kumar
  • 1
  • 1

2 Answers2

0

If vid is a FieldField then try this:

{{ db.vid.file.size|filesizeformat }}
catavaran
  • 44,703
  • 8
  • 98
  • 85
0

filesizeformat as it's name states (and as the official documentation describes) is formatting a file size value and not displaying the filesize itself. If you used the build in File Field for uploading the video, then you can use the already provided .size attribute.

{{db.vid.file.size}}

More information: https://docs.djangoproject.com/en/1.7/ref/files/file/#django.core.files.File.size And: https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#filesizeformat

petkostas
  • 7,250
  • 3
  • 26
  • 29