<commit_before>.. image:: https://travis-ci.org/coddingtonbear/django-measurement.png?branch=master
   :target: https://travis-ci.org/coddingtonbear/django-measurement

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 <https://github.com/django/django/blob/master/django/contrib/gis/measure.py>`_
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 <https://github.com/coddingtonbear/python-measurement>`_.

Example use with a model:

.. code-block:: python

   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 <https://github.com/coddingtonbear/python-measurement>`_
too:

.. code-block:: python

   >>> 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 <http://django-measurement.readthedocs.org/>`_.
- Please post issues on
  `Github <http://github.com/coddingtonbear/django-measurement/issues>`_.
- Test status available on<commit_msg>Update field initialization to match current behavior<commit_after>.. image:: https://travis-ci.org/coddingtonbear/django-measurement.png?branch=master
   :target: https://travis-ci.org/coddingtonbear/django-measurement

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 <https://github.com/django/django/blob/master/django/contrib/gis/measure.py>`_
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 <https://github.com/coddingtonbear/python-measurement>`_.

Example use with a model:

.. code-block:: python

   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 __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 <https://github.com/coddingtonbear/python-measurement>`_
too:

.. code-block:: python

   >>> 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 <http://django-measurement.readthedocs.org/>`_.
- Please post issues on
  `Github <http://github.com/coddingtonbear/django-measurement/issues>`_.
- Test status available on
{'fraction_non_alphanumeric': 0.09828066914498142, 'fraction_numerical': 0.01533457249070632, 'mean_word_length': 4.243605359317905, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 49, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7603170', 'n_tokens_mistral': 1294, 'n_tokens_neox': 1215, 'n_words': 375}