Django Measurement
Easily use, manipulate, and store unit-aware measurement objects using Python and Django.
django.contrib.gis.measure has these wonderful ‘Distance’ objects that can be used not only for storing a unit-aware distance measurement, but also for converting between different units and adding/subtracting these objects from one another.
This module provides for a django model field and admin interface for storing any measurements provided by python-measurement.
Example use with a model:
from django_measurement.models import MeasurementField
from measurement.measures import Volume
from django.db import models
class BeerConsumptionLogEntry(models.Model):
name = models.CharField(max_length=255)
volume = MeasurementField(measurement=Volume)
def __str__(self):
return f"{self.name} of {self.volume}"
entry = BeerConsumptionLogEntry()
entry.name = "Bear Republic Racer 5"
entry.volume = Volume(us_pint=1)
entry.save()
These stored measurement objects can be used in all of the usual ways supported by python-measurement too:
>>> from measurement.measures import Mass
>>> weight_1 = Mass(lb=125)
>>> weight_2 = Mass(kg=40)
>>> added_together = weight_1 + weight_2
>>> added_together
Mass(lb=213.18497680735112)
>>> added_together.kg # Maybe I actually need this value in kg?
96.699
Documentation for django-measurement is available via Read the Docs.
Please post issues on GitHub.
Release files for django-measurement 3.2.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django-measurement-3.2.4.tar.gz | 7.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_measurement-3.2.4-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 14.5 kB
Release files / django-measurement-3.2.4.tar.gz
| Download URL | django-measurement-3.2.4.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db1279b04bacf3b48259312adaaefcfe55ca30b1e0933fa37d6c387c156834d5
|
|
BLAKE2b-256 checksum How to use checksums |
25bef1447df12bc9ed2bbbc1026ed007ac56f6fcaf76ff75bc792ac559b20652
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|
Release files / django_measurement-3.2.4-py2.py3-none-any.whl
| Download URL | django_measurement-3.2.4-py2.py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b2d40b8b56b4e8277130a2a8cbc1f01f597589a636e0ea7dfbc4e4c05d458cef
|
|
BLAKE2b-256 checksum How to use checksums |
9259a343ea0f58f809b4a45451415085805ab30a22b154124ed7227f44535fc9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2
|