This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Convenient fields and classes for handling measurements

Project Description

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 measurement.measures 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.name, 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 Weight
>>> weight_1 = Weight(lb=125)
>>> weight_2 = Weight(kg=40)
>>> added_together = weight_1 + weight_2
>>> added_together
Weight(lb=213.184976807)
>>> added_together.kg  # Maybe I actually need this value in kg?
96.699
  • Documentation for django-measurement is available an ReadTheDocs.
  • Please post issues on Github.
  • Test status available on Travis-CI.
Release History

Release History

This version
History Node

2.4.0

History Node

2.3.0

History Node

2.2.3

History Node

2.2.2

History Node

2.2.1

History Node

2.2.0

History Node

2.1.1

History Node

2.1.0

History Node

2.0.2

History Node

2.0.1

History Node

2.0.0

History Node

1.4

History Node

1.3.3

History Node

1.3.2

History Node

1.3.1

History Node

1.3

History Node

1.2

History Node

1.1

History Node

1.0.2

History Node

1.0.1

History Node

1.0

History Node

0.9.2

History Node

0.9.1

History Node

0.9

History Node

0.8.1

History Node

0.8

History Node

0.7

History Node

0.6

History Node

0.5

History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
django_measurement-2.4.0-py3-none-any.whl (6.3 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Jul 16, 2016
django-measurement-2.4.0.tar.gz (5.0 kB) Copy SHA256 Checksum SHA256 Source Jul 16, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting