Skip to main content

A model field to store a file size, whose edition and display shows units.

Project description

django-sizefield is a file size field, stored as BigInteger and rendered with units in Bytes (KB, MB, …)

https://github.com/leplatrem/django-sizefield/actions/workflows/tests.yml/badge.svg https://coveralls.io/repos/leplatrem/django-sizefield/badge.png

INSTALL

pip install django-sizefield

USAGE

Model field

class Data(models.Model):
    path = models.FilePathField()
    size = FileSizeField()

The model form will have a TextInput, which renders the value with units, and accepts values with or without units.

Template filter

It adds units to any number value:

{% load sizefieldtags %}

{{ value|filesize }}

will render 12.3KB (for example)

AUTHORS

LICENSE

  • Lesser GNU Public License

CHANGELOG

2.0.0 (2020-08-13)

  • Dropped support for python 2

  • Dropped support for Django <2

  • Moved testing to GitHub Actions and tox

1.0.1 (unreleased)

  • Nothing changed yet.

1.0.0 (2019-06-21)

  • Fix support of Django 1.11/2

0.9.1 (2016-04-13)

  • Fix lazy loading of translation infrastructure (#15, thanks @cemiarni).

0.9 (2015-11-12)

  • Add support for unitless values (#13, thanks @megapctr)

0.8 (2015-10-04)

  • Add support for Python3 (thanks @naxube)

0.7 (2015-03-13)

  • Add Zetta and Yotta support (thanks @meteozond)

  • Fix bug with big values (fixes #8, thanks @meteozond)

0.6 (2014-09-25)

  • Add Exabytes support (thanks Matt Pritchard)

0.5 (2014-06-18)

  • Fix template tag not support None values (fixes #4)

  • Support comma notation for float values (fixes #5)

0.4 (2013-08-25)

  • Complete refactor by @perez

0.3 (2013-06-08)

  • South support by @meteozond

0.2 (2013-05-31)

  • Petabytes support by @meteozond

0.1 (2011-01-04)

  • Initial working version.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-sizefield-2.0.0.tar.gz (8.1 kB view details)

Uploaded Source

File details

Details for the file django-sizefield-2.0.0.tar.gz.

File metadata

  • Download URL: django-sizefield-2.0.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.10

File hashes

Hashes for django-sizefield-2.0.0.tar.gz
Algorithm Hash digest
SHA256 b1f74be836bca4e5d8ce0fbfaf920fa2fbab5aa6e791df700c658793fa4b24c4
MD5 da6941a4f0eb7860b653650330a7894b
BLAKE2b-256 55aabb2f7d3517bf2ce52f42ae6309d534ff959296d752c602a61ec45d68cbcc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page