django-quantity-field
A Django application providing model and form field to accept and store multidimensional physical quantities.
Requirements
This application depends on Pint library, used for operate and manipulate physical quantities. Full documentation is available at http://pint.readthedocs.org/
Installation
Install django-quantity-field using pip: pip install django-quantity-field.
Usage
In order to use a quantity field add it to your model definition:
from quantity_field import ureg
from quantity_field.fields import MultiQuantityField
class Package(models.Model):
size = MultiQuantityField(dim=3, units=(ureg.mm, ureg.cm, ureg.m))
weight = MultiQuantityField(units=(ureg.g, ureg.kg))
django-quantity-field comes with the custom form field that is used by default for editing in admin or in your forms.
Accessing MultiQuantityField field will returns MultiQuantity object that can be used as ordinary Pint quantities.
>>> from quantity_field.base import MultiQuantity >>> size = MultiQuantity.from_list(2, 5.5, 4, str(ureg.m)) >>> size <Quantity(44.0, 'meter ** 3')> >>> size.dim 3 >>> [v for v in size] [<Quantity(2.0, 'meter')>, <Quantity(5.5, 'meter')>, <Quantity(4.0, 'meter')>]
Warning
Don’t forget there are no global units in Pint. To use Pint quantities in your project side by side with django-quantity-field use Pint registry from our application.
>>> from quantity_field import ureg
>>> from quantity_field.base import MultiQuantity
>>> box = MultiQuantity.from_string('42 kg')
>>> box + 2.2 * ureg.kg
<Quantity(44.2, 'kilogram')>
Metadata
Release files for django-quantity-field 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| django-quantity-field-1.0.1.tar.gz | 4.8 kB | Without provenance | Details for django-quantity-field-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_quantity_field-1.0.1-py2-none-any.whl | Python 2 | none | any | Details for django_quantity_field-1.0.1-py2-none-any.whl |
Total release size: 13.2 kB
Release files / django-quantity-field-1.0.1.tar.gz
| Download URL | django-quantity-field-1.0.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b19a039a8d7c7cbee3269c296c3c34c7add5d8d705412cc9d8db76f8669d2bb0
|
|
BLAKE2b-256 checksum How to use checksums |
d9356f7fb9971193e3acfc86e66ce0b5e0e2f4f1082443dfb4d22d8a121c6260
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / django_quantity_field-1.0.1-py2-none-any.whl
| Download URL | django_quantity_field-1.0.1-py2-none-any.whl |
|---|---|
| Size | 8.4 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
054c8b325e10c06987424d0a970a19d18c39c0bb0c30b93578db030417d740f0
|
|
BLAKE2b-256 checksum How to use checksums |
8ae1b4eeeb61e2d75d5d3660f6682f5ccb4484b1b2213fb86e4101b179afc4c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-quantity-field 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.