skip to navigation
skip to content

Not Logged In

django-measurement 2.0.0

Convenient fields and classes for handling measurements

Easily use, manipulate, and store unit-aware measurement objects using Python and Django.

Note: Version 2.0 has no backward compatibility due to major design changes.

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 django_measurement.measure import Volume
from django.db import models

class BeerConsumptionLogEntry(models.Model):
    name = models.CharField(max_length=255)
    volume = MeasurementField(Volume)

    def __unicode__(self):
        return u"%s of %s" % (, self.volume)

entry = BeerConsumptionLogEntry() = 'Bear Republic Racer 5'
entry.volume = Volume(us_pint=1)

These stored measurement objects can be used in all of the usual ways supported by python-measurement too:

>>> from django_measurement.measures import Weight
>>> weight_1 = Weight(lb=125)
>>> weight_2 = Weight(kg=40)
>>> added_together = weight_1 + weight_2
>>> added_together
>>>  # Maybe I actually need this value in kg?
  • Documentation for django-measurement is available an ReadTheDocs.
  • Please post issues on Github.
  • Test status available on Travis-CI.
File Type Py Version Uploaded on Size
django-measurement-2.0.0.tar.gz (md5) Source 2015-06-09 4KB
  • Downloads (All Versions):
  • 82 downloads in the last day
  • 488 downloads in the last week
  • 2148 downloads in the last month