django-measurement


Namedjango-measurement JSON
Version 3.2.4 PyPI version JSON
download
home_pagehttps://github.com/coddingtonbear/django-measurement
SummaryConvenient fields and classes for handling measurements
upload_time2022-02-28 08:22:44
maintainer
docs_urlNone
authorAdam Coddington
requires_python
licenseMIT
keywords measurement django
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |version| |ci| |coverage| |license|

Django Measurement
==================

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

`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`_.

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 __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:

.. code-block:: python

   >>> 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_.

.. _Read the Docs: https://django-measurement.readthedocs.io/
.. _GitHub: https://github.com/coddingtonbear/django-measurement/issues
.. _python-measurement: https://github.com/coddingtonbear/python-measurement

.. |version| image:: https://img.shields.io/pypi/v/django-measurement.svg
    :target: https://pypi.python.org/pypi/django-measurement
.. |ci| image:: https://api.travis-ci.org/coddingtonbear/django-measurement.svg?branch=master
    :target: https://travis-ci.org/coddingtonbear/django-measurement
.. |coverage| image:: https://codecov.io/gh/coddingtonbear/django-measurement/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/coddingtonbear/django-measurement
.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg
    :target: LICENSE


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/coddingtonbear/django-measurement",
    "name": "django-measurement",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "measurement,django",
    "author": "Adam Coddington",
    "author_email": "me@adamcoddington.net",
    "download_url": "https://files.pythonhosted.org/packages/25/be/f1447df12bc9ed2bbbc1026ed007ac56f6fcaf76ff75bc792ac559b20652/django-measurement-3.2.4.tar.gz",
    "platform": "",
    "description": "|version| |ci| |coverage| |license|\n\nDjango Measurement\n==================\n\nEasily use, manipulate, and store unit-aware measurement objects using Python\nand Django.\n\n`django.contrib.gis.measure <https://github.com/django/django/blob/master/django/contrib/gis/measure.py>`_\nhas these wonderful 'Distance' objects that can be used not only for storing a\nunit-aware distance measurement, but also for converting between different\nunits and adding/subtracting these objects from one another.\n\nThis module provides for a django model field and admin interface for storing\nany measurements provided by `python-measurement`_.\n\nExample use with a model:\n\n.. code-block:: python\n\n   from django_measurement.models import MeasurementField\n   from measurement.measures import Volume\n   from django.db import models\n   \n   class BeerConsumptionLogEntry(models.Model):\n       name = models.CharField(max_length=255)\n       volume = MeasurementField(measurement=Volume)\n   \n       def __str__(self):\n           return f\"{self.name} of {self.volume}\"\n\n   entry = BeerConsumptionLogEntry()\n   entry.name = \"Bear Republic Racer 5\"\n   entry.volume = Volume(us_pint=1)\n   entry.save()\n\nThese stored measurement objects can be used in all of the usual ways supported\nby `python-measurement`_\ntoo:\n\n.. code-block:: python\n\n   >>> from measurement.measures import Mass\n   >>> weight_1 = Mass(lb=125)\n   >>> weight_2 = Mass(kg=40)\n   >>> added_together = weight_1 + weight_2\n   >>> added_together\n   Mass(lb=213.18497680735112)\n   >>> added_together.kg  # Maybe I actually need this value in kg?\n   96.699\n\n- Documentation for django-measurement is available via `Read the Docs`_.\n- Please post issues on GitHub_.\n\n.. _Read the Docs: https://django-measurement.readthedocs.io/\n.. _GitHub: https://github.com/coddingtonbear/django-measurement/issues\n.. _python-measurement: https://github.com/coddingtonbear/python-measurement\n\n.. |version| image:: https://img.shields.io/pypi/v/django-measurement.svg\n    :target: https://pypi.python.org/pypi/django-measurement\n.. |ci| image:: https://api.travis-ci.org/coddingtonbear/django-measurement.svg?branch=master\n    :target: https://travis-ci.org/coddingtonbear/django-measurement\n.. |coverage| image:: https://codecov.io/gh/coddingtonbear/django-measurement/branch/master/graph/badge.svg\n    :target: https://codecov.io/gh/coddingtonbear/django-measurement\n.. |license| image:: https://img.shields.io/badge/license-MIT-blue.svg\n    :target: LICENSE\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Convenient fields and classes for handling measurements",
    "version": "3.2.4",
    "split_keywords": [
        "measurement",
        "django"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "69ae6a956e1a74dd971ff30fe8c8c3e6",
                "sha256": "b2d40b8b56b4e8277130a2a8cbc1f01f597589a636e0ea7dfbc4e4c05d458cef"
            },
            "downloads": -1,
            "filename": "django_measurement-3.2.4-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "69ae6a956e1a74dd971ff30fe8c8c3e6",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 7227,
            "upload_time": "2022-02-28T08:22:42",
            "upload_time_iso_8601": "2022-02-28T08:22:42.353362Z",
            "url": "https://files.pythonhosted.org/packages/92/59/a343ea0f58f809b4a45451415085805ab30a22b154124ed7227f44535fc9/django_measurement-3.2.4-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "1329080d409fe5856a3e23386a1ed498",
                "sha256": "db1279b04bacf3b48259312adaaefcfe55ca30b1e0933fa37d6c387c156834d5"
            },
            "downloads": -1,
            "filename": "django-measurement-3.2.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1329080d409fe5856a3e23386a1ed498",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7292,
            "upload_time": "2022-02-28T08:22:44",
            "upload_time_iso_8601": "2022-02-28T08:22:44.211630Z",
            "url": "https://files.pythonhosted.org/packages/25/be/f1447df12bc9ed2bbbc1026ed007ac56f6fcaf76ff75bc792ac559b20652/django-measurement-3.2.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-02-28 08:22:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "coddingtonbear",
    "github_project": "django-measurement",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-measurement"
}
        
Elapsed time: 0.08078s