Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Field for Django models that stores multidimensional physical quantities

Project Description

A Django application providing model and form field to accept and store multidimensional physical quantities.


This application depends on Pint library, used for operate and manipulate physical quantities. Full documentation is available at


Install django-quantity-field using pip: pip install django-quantity-field.


In order to use a quantity field add it to your model definition:

from quantity_field import ureg
from quantity_field.fields import MultiQuantityField

class Package(models.Model):
    size = MultiQuantityField(dim=3, units=(,, ureg.m))
    weight = MultiQuantityField(units=(ureg.g,

django-quantity-field comes with the custom form field that is used by default for editing in admin or in your forms.

Accessing MultiQuantityField field will returns MultiQuantity object that can be used as ordinary Pint quantities.

>>> from quantity_field.base import MultiQuantity
>>> size = MultiQuantity.from_list(2, 5.5, 4, str(ureg.m))
>>> size
<Quantity(44.0, 'meter ** 3')>
>>> size.dim
>>> [v for v in size]
[<Quantity(2.0, 'meter')>, <Quantity(5.5, 'meter')>, <Quantity(4.0, 'meter')>]


Don’t forget there are no global units in Pint. To use Pint quantities in your project side by side with django-quantity-field use Pint registry from our application.

>>> from quantity_field import ureg
>>> from quantity_field.base import MultiQuantity
>>> box = MultiQuantity.from_string('42 kg')
>>> box + 2.2 *
<Quantity(44.2, 'kilogram')>

Release History

This version
History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(8.4 kB) Copy SHA256 Hash SHA256
Wheel py2 Nov 11, 2017
(4.8 kB) Copy SHA256 Hash SHA256
Source None Nov 11, 2017

Supported By

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 Google Google Cloud Servers DreamHost DreamHost Log Hosting